aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-11-09 18:55:51 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-11-09 18:56:17 -0800
commitcf378d51fd18166bb34e1dcb60c1a2a1251bdaa6 (patch)
treee800d7edffb6d33b1b9da9041f59f8835a452e67
parent7f5022db0ca839262a862f8e2c8012145c4f90f5 (diff)
downloadbun-cf378d51fd18166bb34e1dcb60c1a2a1251bdaa6.tar.gz
bun-cf378d51fd18166bb34e1dcb60c1a2a1251bdaa6.tar.zst
bun-cf378d51fd18166bb34e1dcb60c1a2a1251bdaa6.zip
Fix broken stacktraces
-rw-r--r--src/bun.js/bindings/ZigGlobalObject.cpp13
-rw-r--r--src/bun.js/bindings/bindings.cpp6
2 files changed, 10 insertions, 9 deletions
diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp
index 34663c228..c01615685 100644
--- a/src/bun.js/bindings/ZigGlobalObject.cpp
+++ b/src/bun.js/bindings/ZigGlobalObject.cpp
@@ -2319,13 +2319,6 @@ void GlobalObject::finishCreation(VM& vm)
Base::finishCreation(vm);
ASSERT(inherits(info()));
- JSC::JSObject* errorConstructor = this->errorConstructor();
- errorConstructor->putDirectNativeFunctionWithoutTransition(vm, this, JSC::Identifier::fromString(vm, "captureStackTrace"_s), 2, errorConstructorFuncCaptureStackTrace, ImplementationVisibility::Public, JSC::NoIntrinsic, PropertyAttribute::DontEnum | 0);
-
- // JSC default is 100
- errorConstructor->deleteProperty(this, vm.propertyNames->stackTraceLimit);
- errorConstructor->putDirect(vm, vm.propertyNames->stackTraceLimit, jsNumber(DEFAULT_ERROR_STACK_TRACE_LIMIT), JSC::PropertyAttribute::DontEnum | 0);
-
// Change prototype from null to object for synthetic modules.
m_moduleNamespaceObjectStructure.initLater(
[](const Initializer<Structure>& init) {
@@ -2579,6 +2572,12 @@ void GlobalObject::finishCreation(VM& vm)
#endif
RELEASE_ASSERT(classInfo());
+
+ JSC::JSObject* errorConstructor = this->errorConstructor();
+ errorConstructor->putDirectNativeFunctionWithoutTransition(vm, this, JSC::Identifier::fromString(vm, "captureStackTrace"_s), 2, errorConstructorFuncCaptureStackTrace, ImplementationVisibility::Public, JSC::NoIntrinsic, PropertyAttribute::DontEnum | 0);
+
+ // JSC default is 100
+ errorConstructor->putDirect(vm, vm.propertyNames->stackTraceLimit, jsNumber(DEFAULT_ERROR_STACK_TRACE_LIMIT), JSC::PropertyAttribute::DontEnum | 0);
}
JSC_DEFINE_HOST_FUNCTION(functionBunPeek,
diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp
index d9c4e3cd7..25a1b3fc7 100644
--- a/src/bun.js/bindings/bindings.cpp
+++ b/src/bun.js/bindings/bindings.cpp
@@ -927,9 +927,11 @@ JSC__JSValue JSC__JSModuleLoader__evaluate(JSC__JSGlobalObject* globalObject, co
promise->rejectWithCaughtException(globalObject, scope);
}
- if (promise->status(vm) == JSC::JSPromise::Status::Fulfilled) {
+ auto status = promise->status(vm);
+
+ if (status == JSC::JSPromise::Status::Fulfilled) {
return JSC::JSValue::encode(promise->result(vm));
- } else if (promise->status(vm) == JSC::JSPromise::Status::Rejected) {
+ } else if (status == JSC::JSPromise::Status::Rejected) {
*arg6 = JSC::JSValue::encode(promise->result(vm));
return JSC::JSValue::encode(JSC::jsUndefined());
} else {