From 9effd4df3141b83c0f4340d34358e96c1931a926 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Tue, 23 Sep 2025 00:05:54 -0700 Subject: [PATCH] fix worker.test.ts --- src/bun.js/bindings/JSGlobalObject.zig | 3 +-- src/bun.js/bindings/ZigGlobalObject.cpp | 5 ++++- src/bun.js/bindings/bindings.cpp | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/bun.js/bindings/JSGlobalObject.zig b/src/bun.js/bindings/JSGlobalObject.zig index 5642205a9d..51225521f7 100644 --- a/src/bun.js/bindings/JSGlobalObject.zig +++ b/src/bun.js/bindings/JSGlobalObject.zig @@ -596,9 +596,8 @@ pub const JSGlobalObject = opaque { return @as(*jsc.VirtualMachine, @ptrCast(@alignCast(this.bunVMUnsafe()))); } - extern fn JSC__JSGlobalObject__handleRejectedPromises(*JSGlobalObject) void; pub fn handleRejectedPromises(this: *JSGlobalObject) void { - return bun.jsc.fromJSHostCallGeneric(this, @src(), JSC__JSGlobalObject__handleRejectedPromises, .{this}) catch @panic("unreachable"); + return bun.cpp.JSC__JSGlobalObject__handleRejectedPromises(this); } extern fn ZigGlobalObject__readableStreamToArrayBuffer(*JSGlobalObject, JSValue) JSValue; diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index 8fddc3fc9f..64e84c4bb5 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -4059,7 +4059,10 @@ void GlobalObject::handleRejectedPromises() continue; Bun__handleRejectedPromise(this, promise); - if (auto ex = scope.exception()) this->reportUncaughtExceptionAtEventLoop(this, ex); + if (auto ex = scope.exception()) { + scope.clearException(); + this->reportUncaughtExceptionAtEventLoop(this, ex); + } } } diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp index 7f5265754c..320ab6afec 100644 --- a/src/bun.js/bindings/bindings.cpp +++ b/src/bun.js/bindings/bindings.cpp @@ -3649,6 +3649,7 @@ JSC::EncodedJSValue JSC__JSGlobalObject__generateHeapSnapshot(JSC::JSGlobalObjec JSC::VM* JSC__JSGlobalObject__vm(JSC::JSGlobalObject* arg0) { return &arg0->vm(); }; +[[ZIG_EXPORT(nothrow)]] void JSC__JSGlobalObject__handleRejectedPromises(JSC::JSGlobalObject* arg0) { return jsCast(arg0)->handleRejectedPromises();