mirror of
https://github.com/oven-sh/bun
synced 2026-02-15 05:12:29 +00:00
fix some worker-related stability issues (#11494)
This commit is contained in:
@@ -752,7 +752,7 @@ pub const VirtualMachine = struct {
|
||||
return this.debugger != null;
|
||||
}
|
||||
|
||||
pub inline fn isShuttingDown(this: *const VirtualMachine) bool {
|
||||
pub fn isShuttingDown(this: *const VirtualMachine) bool {
|
||||
return this.is_shutting_down;
|
||||
}
|
||||
|
||||
@@ -924,6 +924,11 @@ pub const VirtualMachine = struct {
|
||||
extern fn Bun__Process__exit(*JSC.JSGlobalObject, code: c_int) noreturn;
|
||||
|
||||
pub fn unhandledRejection(this: *JSC.VirtualMachine, globalObject: *JSC.JSGlobalObject, reason: JSC.JSValue, promise: JSC.JSValue) bool {
|
||||
if (this.isShuttingDown()) {
|
||||
Output.debugWarn("unhandledRejection during shutdown.", .{});
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isBunTest) {
|
||||
this.unhandled_error_counter += 1;
|
||||
this.onUnhandledRejection(this, globalObject, reason);
|
||||
@@ -939,6 +944,11 @@ pub const VirtualMachine = struct {
|
||||
}
|
||||
|
||||
pub fn uncaughtException(this: *JSC.VirtualMachine, globalObject: *JSC.JSGlobalObject, err: JSC.JSValue, is_rejection: bool) bool {
|
||||
if (this.isShuttingDown()) {
|
||||
Output.debugWarn("uncaughtException during shutdown.", .{});
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isBunTest) {
|
||||
this.unhandled_error_counter += 1;
|
||||
this.onUnhandledRejection(this, globalObject, err);
|
||||
@@ -1066,9 +1076,13 @@ pub const VirtualMachine = struct {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn scriptExecutionStatus(this: *VirtualMachine) callconv(.C) JSC.ScriptExecutionStatus {
|
||||
pub fn scriptExecutionStatus(this: *const VirtualMachine) callconv(.C) JSC.ScriptExecutionStatus {
|
||||
if (this.is_shutting_down) {
|
||||
return .stopped;
|
||||
}
|
||||
|
||||
if (this.worker) |worker| {
|
||||
if (worker.requested_terminate) {
|
||||
if (worker.hasRequestedTerminate()) {
|
||||
return .stopped;
|
||||
}
|
||||
}
|
||||
@@ -2463,7 +2477,7 @@ pub const VirtualMachine = struct {
|
||||
.Internal = promise,
|
||||
});
|
||||
if (this.worker) |worker| {
|
||||
if (worker.requested_terminate) {
|
||||
if (worker.hasRequestedTerminate()) {
|
||||
return error.WorkerTerminated;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user