diff options
| author | 2022-12-02 22:30:04 -0800 | |
|---|---|---|
| committer | 2022-12-02 22:30:04 -0800 | |
| commit | 1b7b37232eb0e9e36e9d5f693e14a5d9bc74efbd (patch) | |
| tree | 059eaa793277d3243575d19fc35826c02d7b0c26 | |
| parent | fe4f39fd17b8ffbb809871b9e4c6550063f15657 (diff) | |
| download | bun-1b7b37232eb0e9e36e9d5f693e14a5d9bc74efbd.tar.gz bun-1b7b37232eb0e9e36e9d5f693e14a5d9bc74efbd.tar.zst bun-1b7b37232eb0e9e36e9d5f693e14a5d9bc74efbd.zip | |
Run promise before callback
Diffstat (limited to '')
| -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();      } | 
