aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bun.js/bindings/CommonJSModuleRecord.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/bun.js/bindings/CommonJSModuleRecord.cpp b/src/bun.js/bindings/CommonJSModuleRecord.cpp
index dc58e35aa..11cd7b727 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);