Replies: 1 comment
-
fixed in #1010 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi guys, I'm trying to fix the promise silently ignore unhandled rejections in bun, which has become annoying for debugging. Need some help for that :P
For now, I'm learning from react-native (another big project using JSC), they are using the
reject-tracking.js
from then/promise and add some js code like:https://github.com/facebook/react-native/blob/v0.60.0/Libraries/Promise.js
The basic logic is that when a promise is rejected and have no further state at the moment, use
setTimeout(onUnhandle, 100)
to register the callback. And if the promise is handled within 100ms,clearTimeout
on the callback.I think we may need to introduce such mechanism to bun and wonder what can we do to make it happen. For example, can we simply polyfill the same mechanism in js or it has to be done within zig and manipulate the event loop directly? (I'm not sure if bun handle promise by its own event loop).
Also, for those who may be interested, JSC does have a callback for unhandled rejected promise:
https://github.com/WebKit/WebKit/blob/95858e6cc2e3f804cc95b4f55cd7532329db790a/Source/JavaScriptCore/runtime/JSGlobalObject.h#L1044
however, it may not be able to raise exception because it seems to me, the exception is cleaned after calling the callback:
https://github.com/WebKit/WebKit/blob/95858e6cc2e3f804cc95b4f55cd7532329db790a/Source/JavaScriptCore/runtime/VM.cpp#L1213-L1229
relates to #953
gently ping @Jarred-Sumner
Beta Was this translation helpful? Give feedback.
All reactions