summaryrefslogtreecommitdiff
path: root/src/node_worker.cc
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2018-09-18 12:29:40 +0200
committerRich Trott <rtrott@gmail.com>2018-09-18 21:26:46 -0700
commite6d0ced7bbe9f48aa1e4e30be8f88b1db0235a62 (patch)
tree4a1793f8d0991dc3cf3ef0bb6780b6a9d0ce27ab /src/node_worker.cc
parenta7b59d6204656f45abb91158648f19687b7c73b0 (diff)
downloadnode-new-e6d0ced7bbe9f48aa1e4e30be8f88b1db0235a62.tar.gz
worker: only stop inspector if started
This may fix some flakiness with tests that use `worker.terminate()`. In particular, the following failure seems like it could be related (no consistent reproduction available, though): ``` 15:30:14 not ok 187 parallel/test-heapdump-worker 15:30:14 --- 15:30:14 duration_ms: 2.499 15:30:14 severity: fail 15:30:14 exitcode: 134 15:30:14 stack: |- 15:30:14 npm[6904]: src\inspector_agent.cc:729: Assertion `(client_) != nullptr' failed. ``` From https://ci.nodejs.org/job/node-test-binary-windows/20041/COMPILED_BY=vs2017,RUNNER=win2016,RUN_SUBSET=2/console Refs: https://github.com/nodejs/node/pull/22769 PR-URL: https://github.com/nodejs/node/pull/22927 Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Diffstat (limited to 'src/node_worker.cc')
-rw-r--r--src/node_worker.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/node_worker.cc b/src/node_worker.cc
index 209b7a4d09..675c3e03a0 100644
--- a/src/node_worker.cc
+++ b/src/node_worker.cc
@@ -150,6 +150,7 @@ void Worker::Run() {
TRACE_STR_COPY(name.c_str()));
MultiIsolatePlatform* platform = isolate_data_->platform();
CHECK_NE(platform, nullptr);
+ bool inspector_started = false;
Debug(this, "Starting worker with id %llu", thread_id_);
{
@@ -177,6 +178,9 @@ void Worker::Run() {
}
if (!is_stopped()) {
+ StartWorkerInspector(env_.get(), url_);
+ inspector_started = true;
+
HandleScope handle_scope(isolate_);
Environment::AsyncCallbackScope callback_scope(env_.get());
env_->async_hooks()->push_async_ids(1, 0);
@@ -185,7 +189,6 @@ void Worker::Run() {
env_->async_hooks()->pop_async_id(1);
Debug(this, "Loaded environment for worker %llu", thread_id_);
- StartWorkerInspector(env_.get(), url_);
}
{
@@ -246,7 +249,8 @@ void Worker::Run() {
env_->stop_sub_worker_contexts();
env_->RunCleanup();
RunAtExit(env_.get());
- WaitForWorkerInspectorToStop(env_.get());
+ if (inspector_started)
+ WaitForWorkerInspectorToStop(env_.get());
{
Mutex::ScopedLock stopped_lock(stopped_mutex_);