Skip to content

Commit a095ef0

Browse files
addaleaxcodebytere
authored andcommitted
src: keep main-thread Isolate attached to platform during Dispose
This works around a situation in which the V8 WASM code calls into the platform while the Isolate is being disposed. This goes against the V8 API constract for `v8::Platform`. In lieu of a proper fix, it should be okay to keep the Isolate registered; the race condition fixed by 25447d8 cannot occur for the `NodeMainInstance`’s Isolate, as it is the last one to exit in any given Node.js process. This partially reverts 25447d8. Refs: #30909 Refs: #31752 PR-URL: #31795 Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent a840e9d commit a095ef0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/node_main_instance.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,12 @@ NodeMainInstance::~NodeMainInstance() {
102102
if (!owns_isolate_) {
103103
return;
104104
}
105-
platform_->UnregisterIsolate(isolate_);
105+
// TODO(addaleax): Reverse the order of these calls. The fact that we first
106+
// dispose the Isolate is a temporary workaround for
107+
// https://github.com/nodejs/node/issues/31752 -- V8 should not be posting
108+
// platform tasks during Dispose(), but it does in some WASM edge cases.
106109
isolate_->Dispose();
110+
platform_->UnregisterIsolate(isolate_);
107111
}
108112

109113
int NodeMainInstance::Run() {

0 commit comments

Comments
 (0)