tjfontaine / node-addon-layer

A thin C API to create node binary addons with, inspired by JSAPI
38 stars 3 forks source link

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

Open jeffbski opened 10 years ago

jeffbski commented 10 years ago

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 commented 10 years ago

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

vivek-kosuri commented 9 years ago

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