vtshaver icon indicating copy to clipboard operation
vtshaver copied to clipboard

`napi_get_property_names` is buggy in node 10.19

Open artemp opened this issue 5 years ago • 7 comments

napi_get_property_names(_env, _value, &result);

erroneously returns Number type when property name has only digit literals e.g '123'

This has been fixed in node >=12 (tested 12.16.1, 13.12.0) /cc @springmeyer

artemp avatar Apr 09 '20 16:04 artemp

@artemp nice catch. Can you try to track down what change in node core fixed what you are seeing? Also, could this explain https://github.com/mapbox/vtshaver/pull/40 ?

springmeyer avatar Apr 09 '20 16:04 springmeyer

Also, could this explain #40

This btw seemed to me like a v8 behavior rather than node core or Nan related, but I'm not positive.

springmeyer avatar Apr 09 '20 16:04 springmeyer

yep, https://github.com/mapbox/vtshaver/issues/40 looks related. I'll investigate further and add workaround in our code if required. /cc @springmeyer

artemp avatar Apr 09 '20 16:04 artemp

thanks @artemp - I feel pretty good about #40 as a workaround, but let me know if you see a better one.

springmeyer avatar Apr 09 '20 16:04 springmeyer

@springmeyer - re: https://github.com/mapbox/vtshaver/pull/40 fix - ideally we shouldn't use v8 methods from N-api module.

artemp avatar Apr 09 '20 16:04 artemp

ideally we shouldn't use v8 methods from N-api module.

Ah, good point.

springmeyer avatar Apr 09 '20 16:04 springmeyer

Fix

Napi::String Napi::Value::ToString() const;

^^ Returns the Napi::Value coerced to a JavaScript string. /cc @springmeyer

artemp avatar Apr 10 '20 09:04 artemp