Skip to content

Commit a340e10

Browse files
fix(worker): report a worker's __runOnMainThread exception without its isolate handle
The exception a worker's callback threw kept a handle into the worker isolate after RunMainThreadEntry let go of it, so the isolate could be disposed before the event loop reported it, and the report resolved the handle against the main thread's isolate. For a worker's callback the exception now drops the handle while the isolate is still held, and only its message and stack reach Java.
1 parent 168ff7c commit a340e10

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎test-app/runtime/src/main/cpp/CallbackHandlers.cpp‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,8 +772,15 @@ void CallbackHandlers::RunMainThreadEntry(uint64_t key) {
772772

773773
if (tc.HasCaught() &&
774774
!NativeScriptException::ContainUncaughtCallbackException(isolate, tc)) {
775+
NativeScriptException ex(tc);
776+
if (!runtime->IsMainThread()) {
777+
// Reported only after this function lets go of the isolate, which
778+
// its worker may dispose by then, and from the main thread, which
779+
// never enters it: only the message and stack can travel.
780+
ex.ReleaseJsHandle();
781+
}
775782
// surfaces via the event loop's guard as a pending Java exception
776-
throw NativeScriptException(tc);
783+
throw ex;
777784
}
778785
}
779786

0 commit comments

Comments
 (0)