Skip to content
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

Refactor throwing uncaught exceptions from callbacks dispatched onto the event loop from C++ #6772

Open
kraenhansen opened this issue Jun 28, 2024 · 1 comment · May be fixed by #6800
Open

Comments

@kraenhansen
Copy link
Member

kraenhansen commented Jun 28, 2024

We should find a more general approach (ideally driven by the binding generator templates) to throw uncaught exceptions when JS callbacks dispatched on the event loop from C++, throws. We're currently wrapping some of our listener APIs in a pattern that catch errors from callback and use setImmediate to rethrow from a new task scheduled from JS, but we have many callbacks that doesn't have this manual "workaround".

I've pushed https://github.com/realm/realm-js/tree/kh/fix-throwing-callbacks as a starting point, disabling the workaround and adding a few failing tests that are now causing aborts.


My current thinking is that we should implement platform specific "EventLoopDispatchers" wrapping Core's util::EventLoopDispatcher used here:

return shouldBlock ? `schedulerWrapBlockingFunction(${lambda})` : `util::EventLoopDispatcher(${lambda})`;
or a realm::util::Scheduler and set this as "default" the way I did in #6791. The platform dispatcher should wrap the lambda with a try-catch which reports the error as an uncaught exception using platform specific runtime APIs.

Copy link

sync-by-unito bot commented Jun 28, 2024

➤ PM Bot commented:

Jira ticket: RJS-2854

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant