Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/node_worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,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_);
{
Expand Down Expand Up @@ -163,6 +164,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);
Expand All @@ -171,7 +175,6 @@ void Worker::Run() {
env_->async_hooks()->pop_async_id(1);

Debug(this, "Loaded environment for worker %llu", thread_id_);
StartWorkerInspector(env_.get(), url_);
}

{
Expand Down Expand Up @@ -232,7 +235,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_);
Expand Down