From 132ab63a32e6f767b96e7cd117281de5a4684ce2 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Fri, 2 Jun 2023 16:39:16 -0700 Subject: [PATCH] Add comment --- src/bun.js/bindings/CommonJSModuleRecord.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/bun.js/bindings/CommonJSModuleRecord.cpp b/src/bun.js/bindings/CommonJSModuleRecord.cpp index dc58e35aa9..11cd7b7274 100644 --- a/src/bun.js/bindings/CommonJSModuleRecord.cpp +++ b/src/bun.js/bindings/CommonJSModuleRecord.cpp @@ -391,6 +391,8 @@ JSC::SourceCode createCommonJSModule( // to pass to that and it isn't used directly much, so that // seems harder to do correctly. { + // We must use a global scope extension or else the JSWithScope will be collected unexpectedly. + // https://github.com/oven-sh/issues/3161 globalObject->clearGlobalScopeExtension(); JSWithScope* withScope = JSWithScope::create(vm, globalObject, globalObject->globalScope(), scopeExtensionObject);