-
Notifications
You must be signed in to change notification settings - Fork 501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using Nan::MakeCallback
and handling exceptions thrown from JS
#668
Comments
You could call an empty js function using |
Interesting; so basically switch [back] to using If the behavior change in v6+ where the exception is marshalled back to C++ is expected, I could try to target the fix to just the affected versions. Any thought of patching this in Nan itself? |
Cannot do anything. All |
For now, I went the route of just kicking the next tick with an empty function. For reference, here's the implementation of that: Thanks for the pointer; this isn't ideal, but it seems to get the job done. |
I've been tracking down the source of random 'hangs' when using the edge module on node >v0.10 (see tjanczuk/edge#325 for one example). The module was calling
v8::Function::Call
instead ofNan::MakeCallback
to call JS async callbacks; per #284 (comment), I realize this is bad, and can result in the next tick never happening (which is exactly the scenario we're hitting).Updating the module to use
Nan::MakeCallback
andNan::Callback
fixes the problem, but creates another one: exceptions thrown in the JS callback are just swallowed and not passed back to C++ as they are withv8::Function::Call
. This behavior does seem to be changed in Node v6+, and exceptions are properly propagated back to C++.For earlier versions (>0.10 and <6), is there any way to achieve consistent behavior and have JS exceptions propagate back to C++? Alternately, is there another approach to kicking off the next tick, if we continue to call
v8::Function::Call
(orNan::Call
) directly?The text was updated successfully, but these errors were encountered: