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

worker: fix --abort-on-uncaught-exception handling #34724

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/api/environment.cc
Expand Up @@ -43,6 +43,7 @@ static bool ShouldAbortOnUncaughtException(Isolate* isolate) {
Environment* env = Environment::GetCurrent(isolate);
return env != nullptr &&
(env->is_main_thread() || !env->is_stopping()) &&
env->abort_on_uncaught_exception() &&
env->should_abort_on_uncaught_toggle()[0] &&
!env->inside_should_not_abort_on_uncaught_scope();
}
Expand Down
2 changes: 1 addition & 1 deletion src/env.cc
Expand Up @@ -359,7 +359,7 @@ Environment::Environment(IsolateData* isolate_data,
inspector_host_port_.reset(
new ExclusiveAccess<HostPort>(options_->debug_options().host_port));

if (flags & EnvironmentFlags::kOwnsProcessState) {
if (!(flags_ & EnvironmentFlags::kOwnsProcessState)) {
set_abort_on_uncaught_exception(false);
}

Expand Down
12 changes: 12 additions & 0 deletions test/parallel/test-worker-abort-on-uncaught-exception.js
@@ -0,0 +1,12 @@
// Flags: --abort-on-uncaught-exception
'use strict';
const common = require('../common');
const assert = require('assert');
const { Worker } = require('worker_threads');

// Tests that --abort-on-uncaught-exception does not apply to
// Workers.

const w = new Worker('throw new Error()', { eval: true });
w.on('error', common.mustCall());
w.on('exit', common.mustCall((code) => assert.strictEqual(code, 1)));