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
can cause a crash in Node.js 14.x in REPL - I was not able to reproduce in a later version and maybe it does not happen.
The type-ahead displaying in REPL has some very special peculiarities and constructors can fail - I suppose because it uses an eval context without globals - which it can detect, catch and ignore. In particular, a constructor can throw a null value. In this case, node-addon-api will be unable to create an Error object - it will fail with the above error.
I won't bother with a minimal reproduction, since it probably won't be fixed anyway, but if you want to see it:
nvm use 14.x
git clone https://github.com/mmomtchev/pymport
npm install
node-pre-gyp configure --debug
node-pre-gyp build
node
> const { PyObject } = require('.');
const a = PyObject.fromJS(4);
> a.co // Start typing a.constr and it will crash, if you copy&paste a.constr everything will be ok
The crash happens when calling FunctionReference::New() - napi_new_instance throws null and the wrapping of the error object in the code cited above fails.
If you short-circuit the error object wrapping, the Node.js REPL correctly catches the null exception and continues without error.
Bypassing node-addon-api and manually re-implementing FunctionReference::New() also fixes the issue.
The text was updated successfully, but these errors were encountered:
I believe this was related to #1000 that was specific to Node.js 14 (fixed in 16 and later).
I am not too certain of the mechanism behind this but it was an issue with V8 IIRC. We attempted to backport that fix into the Node14 line but there was quite a bit of change required so we've abandoned the fix.
This part of the code
node-addon-api/napi-inl.h
Line 2613 in e9db2ad
The type-ahead displaying in REPL has some very special peculiarities and constructors can fail - I suppose because it uses an
eval
context without globals - which it can detect, catch and ignore. In particular, a constructor can throw anull
value. In this case,node-addon-api
will be unable to create anError
object - it will fail with the above error.I won't bother with a minimal reproduction, since it probably won't be fixed anyway, but if you want to see it:
The crash happens when calling
FunctionReference::New()
-napi_new_instance
throwsnull
and the wrapping of the error object in the code cited above fails.If you short-circuit the error object wrapping, the Node.js REPL correctly catches the
null
exception and continues without error.Bypassing
node-addon-api
and manually re-implementingFunctionReference::New()
also fixes the issue.The text was updated successfully, but these errors were encountered: