node-addon-layer icon indicating copy to clipboard operation
node-addon-layer copied to clipboard

External handle is no longer being wrapped in an object for Node 0.11+, how can handle be validated?

Open jeffbski opened this issue 10 years ago • 2 comments

In using the addonlayer, a handle (shim_ctx_t*) is returned and then passed around to be used in additional calls later.

To verify that all the proper values are being passed into our methods, we are doing JS validations on the parameters before calling back into the addon layer, however in Node 0.11.x the validations create a type error when they try to do isNaN(handle) or toString using handle + ''.

TypeError: Cannot convert object to primitive value

I originally had logged this issue against Node, but Fedor Indutny believes the error occurs because of the change in the addon layer, here https://github.com/tjfontaine/node-addon-layer/blob/master/src/shim.cc#L1645

It looks like this change was made purposefully for Node 0.11, so what do you recommend?

I had added a failing test to demonstrate the problem at https://github.com/tjfontaine/node-addon-layer-test/pull/1

jeffbski avatar Aug 27 '14 19:08 jeffbski

Original Node issue was here https://github.com/joyent/node/issues/7993

jeffbski avatar Aug 27 '14 19:08 jeffbski

TJ, wondering if you had a chance to look at this issue?

vivek-kosuri avatar Apr 08 '15 18:04 vivek-kosuri