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
and now if I call require('test').test() it throws error properly. But I would like to throw the error while loading the module, not when the module is loaded.
Now when I call require('test') the process exits immediately. I checked the exit code and it was 0, so the process didn't crash, but obviously the error has not been displayed. My assumption is that Isolate::GetCurrent() doesn't return the isolate I need while the module is loading and it yields in throwing an exception in the wrong isolate, but I am not sure if I am right.
I searched in the documentation and didn't find anything about throwing exception while loading a module. Maybe it would be useful (if the answer is simple enough) to include it in the documentation, imo it is sometimes very useful to perform some initializations while a module is loading and (in case these initialization fail) throw an exception indicating that the module has not been loaded properly.
Thanks.
The text was updated successfully, but these errors were encountered:
this could possibly be related to nodejs/node#19437, although since you don't appear to be using napi i'm not sure. one thing i am sure of is that (at the current time) node only uses one isolate so triggering an exception on the wrong isolate isn't the issue.
Thanks. It seems that the problem is actually fixed in node v9.11.1. I just downloaded and tried, and the exception has been thrown properly. I didn't know this was actually a bug.
I'm trying to throw an error like this
What I currently have
and now if I call
require('test').test()
it throws error properly. But I would like to throw the error while loading the module, not when the module is loaded.What I would like to have
Now when I call
require('test')
the process exits immediately. I checked the exit code and it was0
, so the process didn't crash, but obviously the error has not been displayed. My assumption is thatIsolate::GetCurrent()
doesn't return the isolate I need while the module is loading and it yields in throwing an exception in the wrong isolate, but I am not sure if I am right.I searched in the documentation and didn't find anything about throwing exception while loading a module. Maybe it would be useful (if the answer is simple enough) to include it in the documentation, imo it is sometimes very useful to perform some initializations while a module is loading and (in case these initialization fail) throw an exception indicating that the module has not been loaded properly.
Thanks.
The text was updated successfully, but these errors were encountered: