Get pnpm to run inside bun (#16934)

This commit is contained in:
Jarred Sumner
2025-01-31 04:22:03 -08:00
committed by GitHub
parent 891057cd20
commit 61bf221510
2 changed files with 36 additions and 1 deletions

View File

@@ -15,6 +15,7 @@
#include <JavaScriptCore/GeneratorFunctionPrototype.h>
#include <JavaScriptCore/JSArrayBuffer.h>
#include <JavaScriptCore/ObjectConstructor.h>
#include "ZigGeneratedClasses.h"
#include "NodeUtilTypesModule.h"
@@ -151,7 +152,15 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionIsNativeError,
{
GET_FIRST_VALUE
if (value.isCell()) {
if (value.asCell()->type() == ErrorInstanceType)
JSCell* cell = value.asCell();
if (cell->type() == ErrorInstanceType)
return JSValue::encode(jsBoolean(true));
// Workaround for https://github.com/oven-sh/bun/issues/11780
// They have code that does
// assert(util.types.isNativeError(resolveMessage))
// FIXME: delete this once ResolveMessage and BuildMessage extend Error
if (cell->inherits<WebCore::JSResolveMessage>() || cell->inherits<WebCore::JSBuildMessage>())
return JSValue::encode(jsBoolean(true));
}

View File

@@ -277,3 +277,29 @@ test("isKeyObject", () => {
expect(types.isKeyObject(null)).toBeFalse();
expect(types.isKeyObject(undefined)).toBeFalse();
});
test("#11780", () => {
let resolveError;
try {
resolveError = require("OOGA_BOOGA");
} catch (e) {
resolveError = e;
}
expect(resolveError.constructor.name).toBe("ResolveMessage");
expect(types.isNativeError(resolveError)).toBeTrue();
const badCode = `
export default /BADD~!!!!;
`;
const blob = new Blob([badCode], { type: "application/javascript" });
const url = URL.createObjectURL(blob);
let buildError;
try {
require(url);
} catch (e) {
buildError = e;
}
expect(types.isNativeError(buildError)).toBeTrue();
expect(buildError.constructor.name).toBe("BuildMessage");
});