diff --git a/src/workerd/jsg/setup.c++ b/src/workerd/jsg/setup.c++ index 1b8d4944d06..bc42af642dc 100644 --- a/src/workerd/jsg/setup.c++ +++ b/src/workerd/jsg/setup.c++ @@ -428,8 +428,8 @@ IsolateWithSnapshotCreator newIsolateWithSnapshotCreator(v8::Isolate::CreatePara artifact.externalReferences.asPtr().fill(0); params.external_references = artifact.externalReferences.begin(); - auto creator = kj::heap(params); - v8::Isolate* isolate = creator->GetIsolate(); + v8::Isolate* isolate = v8::Isolate::Allocate(group); + auto creator = kj::heap(isolate, params); return IsolateWithSnapshotCreator{isolate, kj::mv(creator)}; } KJ_CASE_ONEOF(finalizedSnapshot, FinalizedSnapshot) { @@ -605,16 +605,8 @@ IsolateBase::~IsolateBase() noexcept(false) { jsg::runInV8Stack([&](jsg::V8StackScope& stackScope) { // Terminate the v8::platform's task queue associated with this isolate v8System.shutdownIsolate(ptr); - // When preparing a snapshot the v8::SnapshotCreator owns the isolate and keeps it "entered" by - // the current thread; v8::Isolate::Dispose() refuses to run on an entered isolate. Destroy the - // SnapshotCreator first — its destructor exits and disposes the isolate — and skip - // ptr->Dispose() in that case. - if (isPreparingSnapshot()) { - // Destroying the SnapshotCreator exits and disposes its isolate. - snapshotCreator = kj::none; - } else { - ptr->Dispose(); - } + snapshotCreator = kj::none; + ptr->Dispose(); ptr = nullptr; // TODO(cleanup): meaningless after V8 13.4 is released. cppHeap.reset(); diff --git a/src/workerd/server/server.c++ b/src/workerd/server/server.c++ index 3427b53a22b..1f2e35af8e9 100644 --- a/src/workerd/server/server.c++ +++ b/src/workerd/server/server.c++ @@ -5907,7 +5907,7 @@ kj::Own Server::makeWorkerIsolate(kj::StringPtr name, auto jsgobserver = kj::atomicRefcounted(); auto observer = kj::atomicRefcounted(); auto limitEnforcer = kj::refcounted(); - auto isolateGroup = v8::IsolateGroup::GetDefault(); + auto isolateGroup = jsg::newIsolateGroup(); kj::Array listeners; KJ_IF_SOME(l, inboundListeners.find(inboundListenersKey)) {