-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Propagate errors through val coroutine hierarchy. #23653
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
Changes from 1 commit
7ec6306
84ec021
21d9d42
ee390dd
ede5955
233f5a8
41eff7b
0af54ab
f3758df
6b20d96
45010b5
d2a3b92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Fix bug when failure or exception happening in a >1 level of the val coroutine call hierarchy is not being propagated. As a result only deep most level coroutine promise is rejected, other val promises including top most one remain in a perpetual pending state.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -467,33 +467,33 @@ var LibraryEmVal = { | |
return result.done ? 0 : Emval.toHandle(result.value); | ||
}, | ||
|
||
_emval_coro_suspend__deps: ['$Emval', '_emval_coro_resume'], | ||
_emval_coro_suspend: async (promiseHandle, awaiterPtr) => { | ||
var result = await Emval.toValue(promiseHandle); | ||
__emval_coro_resume(awaiterPtr, Emval.toHandle(result)); | ||
_emval_coro_suspend__deps: ['$Emval', '_emval_coro_resume', '_emval_coro_reject'], | ||
_emval_coro_suspend: (promiseHandle, awaiterPtr) => { | ||
Emval.toValue(promiseHandle) | ||
.then(result => __emval_coro_resume(awaiterPtr, Emval.toHandle(result))) | ||
.catch(error => __emval_coro_reject(awaiterPtr, Emval.toHandle(error))); | ||
}, | ||
|
||
_emval_coro_make_promise__deps: ['$Emval', '__cxa_rethrow'], | ||
_emval_coro_make_promise__deps: ['$Emval'], | ||
_emval_coro_make_promise: (resolveHandlePtr, rejectHandlePtr) => { | ||
return Emval.toHandle(new Promise((resolve, reject) => { | ||
const rejectWithCurrentException = () => { | ||
try { | ||
// Use __cxa_rethrow which already has mechanism for generating | ||
// user-friendly error message and stacktrace from C++ exception | ||
// if EXCEPTION_STACK_TRACES is enabled and numeric exception | ||
// with metadata optimised out otherwise. | ||
___cxa_rethrow(); | ||
} catch (e) { | ||
// But catch it so that it rejects the promise instead of throwing | ||
// in an unpredictable place during async execution. | ||
reject(e); | ||
} | ||
}; | ||
|
||
{{{ makeSetValue('resolveHandlePtr', '0', 'Emval.toHandle(resolve)', '*') }}}; | ||
{{{ makeSetValue('rejectHandlePtr', '0', 'Emval.toHandle(rejectWithCurrentException)', '*') }}}; | ||
{{{ makeSetValue('rejectHandlePtr', '0', 'Emval.toHandle(reject)', '*') }}}; | ||
})); | ||
}, | ||
|
||
_emval_coro_exception_to_error__deps: ['$Emval', '__cxa_rethrow'], | ||
_emval_coro_exception_to_error: () => { | ||
RReverser marked this conversation as resolved.
Show resolved
Hide resolved
|
||
try { | ||
// Use __cxa_rethrow which already has mechanism for generating | ||
// user-friendly error message and stacktrace from C++ exception | ||
// if EXCEPTION_STACK_TRACES is enabled and numeric exception | ||
// with metadata optimised out otherwise. | ||
___cxa_rethrow(); | ||
} catch (e) { | ||
return Emval.toHandle(e); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @aheejin does this look reasonable to you? Or is the maybe a better way to do this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we wait for @aheejin's review or merge as-is? This piece of code was before this PR (I added it a while back because it was the only way to make it work that I found at the time), so I'm leaning towards let's merge it anyway. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ping @aheejin |
||
}, | ||
}; | ||
|
||
addToLibrary(LibraryEmVal); |
Uh oh!
There was an error while loading. Please reload this page.