diff --git a/src/node.h b/src/node.h index aadb60ea557f43..d6ec670ae73b7a 100644 --- a/src/node.h +++ b/src/node.h @@ -280,7 +280,6 @@ class NODE_EXTERN MultiIsolatePlatform : public v8::Platform { // This function may only be called once per `Isolate`, and discard any // pending delayed tasks scheduled for that isolate. - // This needs to be called right before calling `Isolate::Dispose()`. virtual void UnregisterIsolate(v8::Isolate* isolate) = 0; // The platform should call the passed function once all state associated diff --git a/src/node_main_instance.cc b/src/node_main_instance.cc index 86a857299f6e90..eea847725300f0 100644 --- a/src/node_main_instance.cc +++ b/src/node_main_instance.cc @@ -99,8 +99,8 @@ NodeMainInstance::~NodeMainInstance() { if (!owns_isolate_) { return; } - platform_->UnregisterIsolate(isolate_); isolate_->Dispose(); + platform_->UnregisterIsolate(isolate_); } int NodeMainInstance::Run() { diff --git a/src/node_worker.cc b/src/node_worker.cc index b89166e9f48ad5..f1b2347d29cbe3 100644 --- a/src/node_worker.cc +++ b/src/node_worker.cc @@ -192,13 +192,8 @@ class WorkerThreadData { *static_cast(data) = true; }, &platform_finished); - // The order of these calls is important; if the Isolate is first disposed - // and then unregistered, there is a race condition window in which no - // new Isolate at the same address can successfully be registered with - // the platform. - // (Refs: https://github.com/nodejs/node/issues/30846) - w_->platform_->UnregisterIsolate(isolate); isolate->Dispose(); + w_->platform_->UnregisterIsolate(isolate); // Wait until the platform has cleaned up all relevant resources. while (!platform_finished) diff --git a/test/cctest/node_test_fixture.h b/test/cctest/node_test_fixture.h index cd669d23da3384..f6b80c860c1f58 100644 --- a/test/cctest/node_test_fixture.h +++ b/test/cctest/node_test_fixture.h @@ -106,9 +106,9 @@ class NodeTestFixture : public ::testing::Test { void TearDown() override { isolate_->Exit(); + isolate_->Dispose(); platform->DrainTasks(isolate_); platform->UnregisterIsolate(isolate_); - isolate_->Dispose(); isolate_ = nullptr; } };