| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 818b280 commit bd40a12
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -158,12 +158,13 @@ void ModuleWrap::New(const FunctionCallbackInfo<Value>& args) { | |||
| 158 | 158 | Context::Scope context_scope(context); | |
| 159 | 159 | ScriptCompiler::Source source(source_text, origin); | |
| 160 | 160 | if (!ScriptCompiler::CompileModule(isolate, &source).ToLocal(&module)) { | |
| 161 | - CHECK(try_catch.HasCaught()); | ||
| 162 | - CHECK(!try_catch.Message().IsEmpty()); | ||
| 163 | - CHECK(!try_catch.Exception().IsEmpty()); | ||
| 164 | - AppendExceptionLine(env, try_catch.Exception(), try_catch.Message(), | ||
| 165 | - ErrorHandlingMode::MODULE_ERROR); | ||
| 166 | - try_catch.ReThrow(); | ||
| 161 | + if (try_catch.HasCaught() && !try_catch.HasTerminated()) { | ||
| 162 | + CHECK(!try_catch.Message().IsEmpty()); | ||
| 163 | + CHECK(!try_catch.Exception().IsEmpty()); | ||
| 164 | + AppendExceptionLine(env, try_catch.Exception(), try_catch.Message(), | ||
| 165 | + ErrorHandlingMode::MODULE_ERROR); | ||
| 166 | + try_catch.ReThrow(); | ||
| 167 | + } | ||
| 167 | 168 | return; | |
| 168 | 169 | } | |
| 169 | 170 | } | |
@@ -245,13 +246,12 @@ void ModuleWrap::Instantiate(const FunctionCallbackInfo<Value>& args) { | |||
| 245 | 246 | Local<Context> context = obj->context_.Get(isolate); | |
| 246 | 247 | Local<Module> module = obj->module_.Get(isolate); | |
| 247 | 248 | TryCatchScope try_catch(env); | |
| 248 | - Maybe<bool> ok = module->InstantiateModule(context, ResolveCallback); | ||
| 249 | + USE(module->InstantiateModule(context, ResolveCallback)); | ||
| 249 | 250 | ||
| 250 | 251 | // clear resolve cache on instantiate | |
| 251 | 252 | obj->resolve_cache_.clear(); | |
| 252 | 253 | ||
| 253 | - if (!ok.FromMaybe(false)) { | ||
| 254 | - CHECK(try_catch.HasCaught()); | ||
| 254 | + if (try_catch.HasCaught() && !try_catch.HasTerminated()) { | ||
| 255 | 255 | CHECK(!try_catch.Message().IsEmpty()); | |
| 256 | 256 | CHECK(!try_catch.Exception().IsEmpty()); | |
| 257 | 257 | AppendExceptionLine(env, try_catch.Exception(), try_catch.Message(), | |
@@ -300,6 +300,8 @@ void ModuleWrap::Evaluate(const FunctionCallbackInfo<Value>& args) { | |||
| 300 | 300 | ||
| 301 | 301 | // Convert the termination exception into a regular exception. | |
| 302 | 302 | if (timed_out || received_signal) { | |
| 303 | + if (!env->is_main_thread() && env->is_stopping_worker()) | ||
| 304 | + return; | ||
| 303 | 305 | env->isolate()->CancelTerminateExecution(); | |
| 304 | 306 | // It is possible that execution was terminated by another timeout in | |
| 305 | 307 | // which this timeout is nested, so check whether one of the watchdogs | |
@@ -312,7 +314,8 @@ void ModuleWrap::Evaluate(const FunctionCallbackInfo<Value>& args) { | |||
| 312 | 314 | } | |
| 313 | 315 | ||
| 314 | 316 | if (try_catch.HasCaught()) { | |
| 315 | - try_catch.ReThrow(); | ||
| 317 | + if (!try_catch.HasTerminated()) | ||
| 318 | + try_catch.ReThrow(); | ||
| 316 | 319 | return; | |
| 317 | 320 | } | |
| 318 | 321 | ||
@@ -375,7 +378,6 @@ void ModuleWrap::GetError(const FunctionCallbackInfo<Value>& args) { | |||
| 375 | 378 | ASSIGN_OR_RETURN_UNWRAP(&obj, args.This()); | |
| 376 | 379 | ||
| 377 | 380 | Local<Module> module = obj->module_.Get(isolate); | |
| 378 | - | ||
| 379 | 381 | args.GetReturnValue().Set(module->GetException()); | |
| 380 | 382 | } | |
| 381 | 383 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -252,7 +252,8 @@ void ContextifyContext::MakeContext(const FunctionCallbackInfo<Value>& args) { | |||
| 252 | 252 | ContextifyContext* context = new ContextifyContext(env, sandbox, options); | |
| 253 | 253 | ||
| 254 | 254 | if (try_catch.HasCaught()) { | |
| 255 | - try_catch.ReThrow(); | ||
| 255 | + if (!try_catch.HasTerminated()) | ||
| 256 | + try_catch.ReThrow(); | ||
| 256 | 257 | return; | |
| 257 | 258 | } | |
| 258 | 259 | ||
@@ -729,7 +730,8 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) { | |||
| 729 | 730 | if (v8_script.IsEmpty()) { | |
| 730 | 731 | DecorateErrorStack(env, try_catch); | |
| 731 | 732 | no_abort_scope.Close(); | |
| 732 | - try_catch.ReThrow(); | ||
| 733 | + if (!try_catch.HasTerminated()) | ||
| 734 | + try_catch.ReThrow(); | ||
| 733 | 735 | TRACE_EVENT_NESTABLE_ASYNC_END0( | |
| 734 | 736 | TRACING_CATEGORY_NODE2(vm, script), | |
| 735 | 737 | "ContextifyScript::New", | |
@@ -922,6 +924,8 @@ bool ContextifyScript::EvalMachine(Environment* env, | |||
| 922 | 924 | ||
| 923 | 925 | // Convert the termination exception into a regular exception. | |
| 924 | 926 | if (timed_out || received_signal) { | |
| 927 | + if (!env->is_main_thread() && env->is_stopping_worker()) | ||
| 928 | + return false; | ||
| 925 | 929 | env->isolate()->CancelTerminateExecution(); | |
| 926 | 930 | // It is possible that execution was terminated by another timeout in | |
| 927 | 931 | // which this timeout is nested, so check whether one of the watchdogs | |
@@ -944,7 +948,8 @@ bool ContextifyScript::EvalMachine(Environment* env, | |||
| 944 | 948 | // letting try_catch catch it. | |
| 945 | 949 | // If execution has been terminated, but not by one of the watchdogs from | |
| 946 | 950 | // this invocation, this will re-throw a `null` value. | |
| 947 | - try_catch.ReThrow(); | ||
| 951 | + if (!try_catch.HasTerminated()) | ||
| 952 | + try_catch.ReThrow(); | ||
| 948 | 953 | ||
| 949 | 954 | return false; | |
| 950 | 955 | } | |
@@ -1098,8 +1103,10 @@ void ContextifyContext::CompileFunction( | |||
| 1098 | 1103 | context_extensions.size(), context_extensions.data(), options); | |
| 1099 | 1104 | ||
| 1100 | 1105 | if (maybe_fn.IsEmpty()) { | |
| 1101 | - DecorateErrorStack(env, try_catch); | ||
| 1102 | - try_catch.ReThrow(); | ||
| 1106 | + if (try_catch.HasCaught() && !try_catch.HasTerminated()) { | ||
| 1107 | + DecorateErrorStack(env, try_catch); | ||
| 1108 | + try_catch.ReThrow(); | ||
| 1109 | + } | ||
| 1103 | 1110 | return; | |
| 1104 | 1111 | } | |
| 1105 | 1112 | Local<Function> fn = maybe_fn.ToLocalChecked(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1 @@ | |||
| 1 | + import exit from "./process-exit.mjs"; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,2 @@ | |||
| 1 | + process.exit(42); | ||
| 2 | + export default null; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,10 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const fixtures = require('../common/fixtures'); | ||
| 4 | + const assert = require('assert'); | ||
| 5 | + const { Worker } = require('worker_threads'); | ||
| 6 | + | ||
| 7 | + const w = new Worker(fixtures.path('es-modules/import-process-exit.mjs'), | ||
| 8 | + { execArgv: ['--experimental-modules'] }); | ||
| 9 | + w.on('error', common.mustNotCall()); | ||
| 10 | + w.on('exit', (code) => assert.strictEqual(code, 42)); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments