diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index 7a258ba524e1dd..9a138e95352b93 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -874,8 +874,9 @@ GlobalObject::~GlobalObject() finalizer(toNapi(this), napiInstanceData, napiInstanceDataFinalizerHint); } - delete m_subtleCrypto; - scriptExecutionContext()->removeFromContextsMap(); + if (auto *ctx = scriptExecutionContext()) { + ctx->removeFromContextsMap(); + } } void GlobalObject::destroy(JSCell* cell)