You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Deprecated warning with nan v2.7.0 and Node.js 9.0.0 #707
When a native module using nan v2.7.0 is installed with Node.js 9.0.0 there is a deprecated warning. For example, here's the warning shown when installing the epoll module:
pi@raspberrypi:~/epoll $ npm i epoll
> epoll@1.0.0 install /home/pi/epoll/node_modules/epoll
> node-gyp rebuild
make: Entering directory '/home/pi/epoll/node_modules/epoll/build'
CXX(target) Release/obj.target/epoll/src/epoll.o
In file included from ../../nan/nan.h:192:0,
from ../src/epoll.cc:15:
../../nan/nan_maybe_43_inl.h: In function ‘Nan::Maybe<bool> Nan::ForceSet(v8::Local<v8::Object>, v8::Local<v8::Value>, v8::Local<v8::Value>, v8::PropertyAttribute)’:
../../nan/nan_maybe_43_inl.h:112:73: warning: ‘v8::Maybe<bool> v8::Object::ForceSet(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>, v8::PropertyAttribute)’ is deprecated: Use CreateDataProperty / DefineOwnProperty [-Wdeprecated-declarations]
return obj->ForceSet(isolate->GetCurrentContext(), key, value, attribs);
^
In file included from /home/pi/.node-gyp/9.0.0/include/node/v8.h:26:0,
from ../src/epoll.cc:11:
/home/pi/.node-gyp/9.0.0/include/node/v8.h:3115:29: note: declared here
Maybe<bool> ForceSet(Local<Context> context, Local<Value> key,
^
/home/pi/.node-gyp/9.0.0/include/node/v8config.h:318:3: note: in definition of macro ‘V8_DEPRECATED’
declarator __attribute__((deprecated(message)))
^~~~~~~~~~
SOLINK_MODULE(target) Release/obj.target/epoll.node
COPY Release/epoll.node
make: Leaving directory '/home/pi/epoll/node_modules/epoll/build'
npm WARN saveError ENOENT: no such file or directory, open '/home/pi/epoll/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/home/pi/epoll/package.json'
npm WARN epoll No description
npm WARN epoll No repository field.
npm WARN epoll No README data
npm WARN epoll No license field.
+ epoll@1.0.0
added 3 packages in 10.643s
pi@raspberrypi:~/epoll $
That is unfortunate. It was only a question of time. ForceSet has been on its way out in V8 for a long time, but if I remember correctly there is no proper alternative, so the fix is not straightforward, if at all possible. Neither CreateDataProperty not DefineOwnProperty offer the same semantics.
Related: #504
If I understand PR #708 correctly, the plan is leave Nan::ForceSet as it is, mark it as deprecated and introduce Nan::DefineOwnProperty.
V8 already has v8::Object::ForceSet marked as deprecated. This results in the deprecation warning shown in the above post irrespective of whether Nan::ForceSet is used by an addon or not.
So if I want to suppress the V8 deprecation warning for v8::Object::ForceSet I'll have to suppress it in my addon because NAN will not be suppressing it, is this correct?
Still accounting for versions. Nan::ForceSet would be marked as deprecated regardless of Node version, but for Node 9 onwards, Nan::ForceSet would be an alias for Nan::DefineOwnProperty. That should not cause any undue warnings.
On November 4, 2017 8:31:17 AM GMT+02:00, Brian Cooke ***@***.***> wrote:
If I understand PR #708 correctly,
the plan is leave Nan::ForceSet as it is, mark it as deprecated and
introduce Nan::DefineOwnProperty.
V8 already has v8::Object::ForceSet marked as deprecated. This results
in the deprecation warning shown in the above post irrespective of
whether Nan::ForceSet is used by an addon or not.
So if I want to suppress the V8 deprecation warning for
v8::Object::ForceSet I'll have to suppress it in my addon because NAN
will not be suppressing it, is this correct?
Activity
kkoopa commentedon Oct 31, 2017
That is unfortunate. It was only a question of time.
ForceSethas been on its way out in V8 for a long time, but if I remember correctly there is no proper alternative, so the fix is not straightforward, if at all possible. NeitherCreateDataPropertynotDefineOwnPropertyoffer the same semantics.Related: #504
fivdi commentedon Nov 4, 2017
If I understand PR #708 correctly, the plan is leave Nan::ForceSet as it is, mark it as deprecated and introduce Nan::DefineOwnProperty.
V8 already has v8::Object::ForceSet marked as deprecated. This results in the deprecation warning shown in the above post irrespective of whether Nan::ForceSet is used by an addon or not.
So if I want to suppress the V8 deprecation warning for v8::Object::ForceSet I'll have to suppress it in my addon because NAN will not be suppressing it, is this correct?
bnoordhuis commentedon Nov 4, 2017
@fivdi Yes, correct.
kkoopa commentedon Nov 4, 2017
Build for Node 9. Note that due to nodejs/nan#707 there'll still be a…
kkoopa commentedon Nov 10, 2017
Fixed in master. New release coming soon.