Fix crash in require.extensions (#18788)

Co-authored-by: 190n <7763597+190n@users.noreply.github.com>
This commit is contained in:
190n
2025-04-04 19:11:32 -07:00
committed by GitHub
parent d1ac711a7e
commit c86097aeb0
10 changed files with 65876 additions and 53346 deletions

View File

@@ -287,4 +287,18 @@ JSC::EncodedJSValue builtinLoader(JSC::JSGlobalObject* globalObject, JSC::CallFr
return JSC::JSValue::encode(jsUndefined());
}
template<typename Visitor>
void JSCommonJSExtensions::visitChildrenImpl(JSCell* cell, Visitor& visitor)
{
JSCommonJSExtensions* thisObject = jsCast<JSCommonJSExtensions*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Base::visitChildren(thisObject, visitor);
for (auto& func : thisObject->m_registeredFunctions) {
visitor.append(func);
}
}
DEFINE_VISIT_CHILDREN(JSCommonJSExtensions);
} // namespace Bun

View File

@@ -41,6 +41,8 @@ public:
return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
}
DECLARE_VISIT_CHILDREN;
protected:
static bool defineOwnProperty(JSC::JSObject*, JSC::JSGlobalObject*, JSC::PropertyName, const JSC::PropertyDescriptor&, bool shouldThrow);
static bool put(JSC::JSCell*, JSC::JSGlobalObject*, JSC::PropertyName, JSC::JSValue, JSC::PutPropertySlot&);

View File

@@ -80,6 +80,7 @@
#include "JSBufferList.h"
#include "JSByteLengthQueuingStrategy.h"
#include "JSCloseEvent.h"
#include "JSCommonJSExtensions.h"
#include "JSCountQueuingStrategy.h"
#include "JSCustomEvent.h"
#include "JSDOMConvertBase.h"
@@ -4060,6 +4061,7 @@ void GlobalObject::visitChildrenImpl(JSCell* cell, Visitor& visitor)
thisObject->m_lazyPreloadTestModuleObject.visit(visitor);
thisObject->m_lazyReadableStreamPrototypeMap.visit(visitor);
thisObject->m_lazyRequireCacheObject.visit(visitor);
thisObject->m_lazyRequireExtensionsObject.visit(visitor);
thisObject->m_lazyTestModuleObject.visit(visitor);
thisObject->m_memoryFootprintStructure.visit(visitor);
thisObject->m_JSStatsClassStructure.visit(visitor);

View File

@@ -554,6 +554,9 @@ export function ospath(path: string) {
*/
export async function toMatchNodeModulesAt(lockfile: any, root: string) {
function shouldSkip(pkg: any, dep: any): boolean {
// Band-aid as toMatchNodeModulesAt will sometimes ask this function
// if a package depends on itself
if (pkg?.name === dep?.name) return true;
return (
!pkg ||
!pkg.resolution ||

File diff suppressed because it is too large Load Diff

View File

@@ -15,13 +15,13 @@
"@types/react-dom": "18.2.7",
"autoprefixer": "10.4.16",
"bun-types": "^1.0.3",
"eslint": "8.50.0",
"eslint-config-next": "14.1.3",
"next": "14.1.3",
"eslint": "^9.24.0",
"eslint-config-next": "^15.2.4",
"next": "^15.2.4",
"postcss": "8.4.30",
"puppeteer": "22.12.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"tailwindcss": "3.3.3",
"typescript": "5.2.2"
}

View File

@@ -181,7 +181,6 @@ test(
"required-server-files.json",
// these have "signing keys", not sure what they are tbh
"prerender-manifest.json",
"prerender-manifest.js",
// these are similar but i feel like there might be something we can fix to make them the same
"next-minimal-server.js.nft.json",
"next-server.js.nft.json",