diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bun.js/api/bun/subprocess.zig | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/bun.js/api/bun/subprocess.zig b/src/bun.js/api/bun/subprocess.zig index 75f1eb05c..ba1aab7ff 100644 --- a/src/bun.js/api/bun/subprocess.zig +++ b/src/bun.js/api/bun/subprocess.zig @@ -1471,6 +1471,19 @@ pub const Subprocess = struct { defer this.updateHasPendingActivity(); this.has_waitpid_task = false; + if (this.exit_promise.trySwap()) |promise| { + if (this.exit_code) |code| { + promise.asPromise().?.resolve(globalThis, JSValue.jsNumber(code)); + } else if (this.waitpid_err) |err| { + this.waitpid_err = null; + promise.asPromise().?.reject(globalThis, err.toJSC(globalThis)); + } else { + // crash in debug mode + if (comptime Environment.allow_assert) + unreachable; + } + } + if (this.on_exit_callback.trySwap()) |callback| { const exit_value: JSValue = if (this.exit_code) |code| JSC.JSValue.jsNumber(code) @@ -1498,19 +1511,6 @@ pub const Subprocess = struct { } } - if (this.exit_promise.trySwap()) |promise| { - if (this.exit_code) |code| { - promise.asPromise().?.resolve(globalThis, JSValue.jsNumber(code)); - } else if (this.waitpid_err) |err| { - this.waitpid_err = null; - promise.asPromise().?.reject(globalThis, err.toJSC(globalThis)); - } else { - // crash in debug mode - if (comptime Environment.allow_assert) - unreachable; - } - } - this.unref(); } |