google/pprof-nodejs

[node 20] Compilation error on nan

yosiat opened this issue · 9 comments

Hi,

I am trying to upgrade to node 20 (from 16) and I see this compilation error:

npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]

npm ERR! In file included from ../../nan/nan.h:178,

npm ERR!                  from ../bindings/profiler.cc:19:

npm ERR! ../../nan/nan_callbacks.h:55:23: error: 'AccessorSignature' is not a member of 'v8'

npm ERR!    55 | typedef v8::Local<v8::AccessorSignature> Sig;

npm ERR!       |                       ^~~~~~~~~~~~~~~~~

npm ERR! ../../nan/nan_callbacks.h:55:40: error: template argument 1 is invalid

npm ERR!    55 | typedef v8::Local<v8::AccessorSignature> Sig;

npm ERR!       |                                        ^

npm ERR! ../../nan/nan.h: In function 'bool Nan::IdleNotification(int)':

npm ERR! ../../nan/nan.h:684:63: warning: 'bool v8::Isolate::IdleNotificationDeadline(double)' is deprecated: Use MemoryPressureNotification() to influence the GC schedule. [-Wdeprecated-declarations]

npm ERR!   684 |     return v8::Isolate::GetCurrent()->IdleNotificationDeadline(

npm ERR!       |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

npm ERR!   685 |         idle_time_in_ms * 0.001);

npm ERR!       |         ~~~~~~~~~~~~~~~~~~~~~~~~                               

npm ERR! In file included from /home/node/.cache/node-gyp/20.10.0/include/node/v8-initialization.h:13,

npm ERR!                  from /home/node/.cache/node-gyp/20.10.0/include/node/v8.h:34,

npm ERR!                  from /home/node/.cache/node-gyp/20.10.0/include/node/node.h:73,

npm ERR!                  from ../../nan/nan.h:58:

npm ERR! /home/node/.cache/node-gyp/20.10.0/include/node/v8-isolate.h:1293:8: note: declared here

npm ERR!  1293 |   bool IdleNotificationDeadline(double deadline_in_seconds);

npm ERR!       |        ^~~~~~~~~~~~~~~~~~~~~~~~

npm ERR! ../../nan/nan.h: In function 'void Nan::SetAccessor(v8::Local<v8::ObjectTemplate>, v8::Local<v8::String>, GetterCallback, SetterCallback, v8::Local<v8::Value>, v8::AccessControl, v8::PropertyAttribute, imp::Sig)':

npm ERR! ../../nan/nan.h:2544:19: error: no matching function for call to 'v8::ObjectTemplate::SetAccessor(v8::Local<v8::String>&, void (*&)(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>&), void (*&)(v8::Local<v8::Name>, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<void>&), v8::Local<v8::Object>&, v8::AccessControl&, v8::PropertyAttribute&, Nan::imp::Sig&)'

npm ERR!  2544 |   tpl->SetAccessor(

npm ERR!       |   ~~~~~~~~~~~~~~~~^

npm ERR!  2545 |       name

npm ERR!       |       ~~~~         

npm ERR!  2546 |     , getter_

npm ERR!       |     ~~~~~~~~~      

npm ERR!  2547 |     , setter_

npm ERR!       |     ~~~~~~~~~      

npm ERR!  2548 |     , obj

npm ERR!       |     ~~~~~          

npm ERR!  2549 |     , settings

npm ERR!       |     ~~~~~~~~~~     

npm ERR!  2550 |     , attribute

npm ERR!       |     ~~~~~~~~~~~    

npm ERR!  2551 |     , signature);

npm ERR!       |     ~~~~~~~~~~~~   

npm ERR! In file included from /home/node/.cache/node-gyp/20.10.0/include/node/v8-function.h:15,

npm ERR!                  from /home/node/.cache/node-gyp/20.10.0/include/node/v8.h:33:

npm ERR! /home/node/.cache/node-gyp/20.10.0/include/node/v8-template.h:809:8: note: candidate: 'void v8::ObjectTemplate::SetAccessor(v8::Local<v8::String>, v8::AccessorGetterCallback, v8::AccessorSetterCallback, v8::Local<v8::Value>, v8::AccessControl, v8::PropertyAttribute, v8::SideEffectType, v8::SideEffectType)'

npm ERR!   809 |   void SetAccessor(

npm ERR!       |        ^~~~~~~~~~~

npm ERR! /home/node/.cache/node-gyp/20.10.0/include/node/v8-template.h:814:22: note:   no known conversion for argument 7 from 'Nan::imp::Sig' {aka 'int'} to 'v8::SideEffectType'

npm ERR!   814 |       SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,

npm ERR!       |       ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

npm ERR! /home/node/.cache/node-gyp/20.10.0/include/node/v8-template.h:816:8: note: candidate: 'void v8::ObjectTemplate::SetAccessor(v8::Local<v8::Name>, v8::AccessorNameGetterCallback, v8::AccessorNameSetterCallback, v8::Local<v8::Value>, v8::AccessControl, v8::PropertyAttribute, v8::SideEffectType, v8::SideEffectType)'

npm ERR!   816 |   void SetAccessor(

npm ERR!       |        ^~~~~~~~~~~

npm ERR! /home/node/.cache/node-gyp/20.10.0/include/node/v8-template.h:821:22: note:   no known conversion for argument 7 from 'Nan::imp::Sig' {aka 'int'} to 'v8::SideEffectType'

npm ERR!   821 |       SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,

npm ERR!       |       ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

npm ERR! make: *** [pprof.target.mk:115: Release/obj.target/pprof/bindings/profiler.o] Error 1

npm ERR! gyp ERR! build error 

This issue looks like it's fixed in nan 2.17.0 - https://github.com/nodejs/nan/blob/main/CHANGELOG.md#2170-oct-10-2022

Is it possible to upgrade this dependency?

Thanks for flagging this. It's actually fixed on main, we just need a release.

Thanks @aabmass , I saw it was released as 3.3.0 which is deprecated release.

Yes, I deprecated that one. IIRC it contained accidental breaking changes which should have been a major bump. I made a patch release instead to fix it

hey @aabmass is there any update on this one?

we are blocked on node 18 because of this, and the fix should be simple (unless I am missing something) - change nan from 2.14.0 to 2.17.0

@yosiat I'm working on a release right now. However, after checking what was published in pprof@3.2.1, I notice the version of nan has a carat dependency:

"nan": "^2.14.0",

IOW, you should be able to install it in Node 20 today. You might have an older version of nan in your package-lock.json. Please try upgrading nan–I tested it in a fresh repo and it works.

@aabmass I agree with you that carat should work here, but it doesn't work as expected in my project.

It keeps installing nan v2.15.0 (and there is no other module depending on it except pprof), the only trick that worked is npm install nan and then npm uninstall nan, which is a bit weird one.

@yosiat I'm guessing it was probably stale from either your package-lock.json or in node_modules directory

Just published v4.0.0

Thanks a lot!