Skip to content

Commit f21db6f

Browse files
authored
fix(worker): consult the termination-requested flag at the last two failure sites
The CommonJS module-function call and the ES module Evaluate failure only recognized a termination V8 had already materialized. A request that landed during the call, before any JS ran to materialize it, let an ordinary failure be formatted as an error on a terminating isolate. Both sites now read the same three signals as the settle pump and the require path.
1 parent 7427288 commit f21db6f

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎NativeScript/runtime/ModuleInternal.mm‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,9 @@ throw NativeScriptException(isolate,
894894
moduleFunc->Call(context, thiz, sizeof(requireArgs) / sizeof(Local<Value>), requireArgs)
895895
.ToLocal(&result);
896896
if (!success || tc.HasCaught()) {
897-
if (tc.HasTerminated()) {
897+
Runtime* runtime = Runtime::GetRuntime(isolate);
898+
if (tc.HasTerminated() || isolate->IsExecutionTerminating() ||
899+
(runtime != nullptr && runtime->IsTerminationRequested())) {
898900
throw NativeScriptException("Module evaluation interrupted by isolate termination: " +
899901
modulePath);
900902
}
@@ -1295,7 +1297,9 @@ throw NativeScriptException(
12951297
RemoveModuleFromRegistry(isolate, canonicalPath);
12961298
// Same rule as the pump below: a termination outranks any failure detail,
12971299
// and reading the TryCatch as an error would run JS on the dying isolate.
1298-
if (tcEval.HasTerminated() || isolate->IsExecutionTerminating()) {
1300+
Runtime* runtime = Runtime::GetRuntime(isolate);
1301+
if (tcEval.HasTerminated() || isolate->IsExecutionTerminating() ||
1302+
(runtime != nullptr && runtime->IsTerminationRequested())) {
12991303
LogEsmPhase(canonicalPath, "evaluate", "terminated");
13001304
throw NativeScriptException("Module evaluation interrupted by isolate termination: " +
13011305
canonicalPath);

0 commit comments

Comments
 (0)