diff options
Diffstat (limited to 'src/bun.js/javascript.zig')
-rw-r--r-- | src/bun.js/javascript.zig | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig index f54dd5fb8..3841a07e2 100644 --- a/src/bun.js/javascript.zig +++ b/src/bun.js/javascript.zig @@ -362,6 +362,7 @@ pub const VirtualMachine = struct { uws_event_loop: ?*uws.Loop = null, pending_unref_counter: i32 = 0, preload: []const string = &[_][]const u8{}, + unhandled_pending_rejection_to_capture: ?*JSC.JSValue = null, /// hide bun:wrap from stack traces /// bun:wrap is very noisy @@ -479,6 +480,14 @@ pub const VirtualMachine = struct { this.unhandled_error_counter += 1; } + pub fn onQuietUnhandledRejectionHandlerCaptureValue(this: *VirtualMachine, _: *JSC.JSGlobalObject, value: JSC.JSValue) void { + this.unhandled_error_counter += 1; + value.ensureStillAlive(); + if (this.unhandled_pending_rejection_to_capture) |ptr| { + ptr.* = value; + } + } + pub fn unhandledRejectionScope(this: *VirtualMachine) UnhandledRejectionScope { return .{ .onUnhandledRejection = this.onUnhandledRejection, |