Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 513ab0e

Browse filesBrowse files
addaleaxBethGriggs
authored andcommitted
worker: fix --abort-on-uncaught-exception handling
The `set_abort_on_uncaught_exception(false)` line was supposed to prevent aborting when running Workers in `--abort-on-uncaught-exception` mode, but it was incorrectly set and not checked properly in the should-abort callback. PR-URL: #34724 Backport-PR-URL: #34815 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Mary Marchini <oss@mmarchini.me>
1 parent 03d6013 commit 513ab0e
Copy full SHA for 513ab0e

File tree

Expand file treeCollapse file tree

3 files changed

+17
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+17
-3
lines changed
Open diff view settings
Collapse file

‎src/api/environment.cc‎

Copy file name to clipboardExpand all lines: src/api/environment.cc
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ static bool ShouldAbortOnUncaughtException(Isolate* isolate) {
4242
Environment* env = Environment::GetCurrent(isolate);
4343
return env != nullptr &&
4444
(env->is_main_thread() || !env->is_stopping()) &&
45+
env->abort_on_uncaught_exception() &&
4546
env->should_abort_on_uncaught_toggle()[0] &&
4647
!env->inside_should_not_abort_on_uncaught_scope();
4748
}
@@ -355,9 +356,6 @@ Environment* CreateEnvironment(
355356
exec_args,
356357
flags,
357358
thread_id);
358-
if (flags & EnvironmentFlags::kOwnsProcessState) {
359-
env->set_abort_on_uncaught_exception(false);
360-
}
361359

362360
#if HAVE_INSPECTOR
363361
if (inspector_parent_handle) {
Collapse file

‎src/env.cc‎

Copy file name to clipboardExpand all lines: src/env.cc
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,10 @@ Environment::Environment(IsolateData* isolate_data,
348348
inspector_host_port_.reset(
349349
new ExclusiveAccess<HostPort>(options_->debug_options().host_port));
350350

351+
if (!(flags_ & EnvironmentFlags::kOwnsProcessState)) {
352+
set_abort_on_uncaught_exception(false);
353+
}
354+
351355
#if HAVE_INSPECTOR
352356
// We can only create the inspector agent after having cloned the options.
353357
inspector_agent_ = std::make_unique<inspector::Agent>(this);
Collapse file
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Flags: --abort-on-uncaught-exception
2+
'use strict';
3+
const common = require('../common');
4+
const assert = require('assert');
5+
const { Worker } = require('worker_threads');
6+
7+
// Tests that --abort-on-uncaught-exception does not apply to
8+
// Workers.
9+
10+
const w = new Worker('throw new Error()', { eval: true });
11+
w.on('error', common.mustCall());
12+
w.on('exit', common.mustCall((code) => assert.strictEqual(code, 1)));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.