diff options
author | 2023-05-11 14:39:44 -0700 | |
---|---|---|
committer | 2023-05-11 14:39:44 -0700 | |
commit | 02cad591f8c56f801fb9ccc480bf9547484144c2 (patch) | |
tree | 544dd92627fb4efd5d53842ce660f6e7a567efa3 | |
parent | 3530cfac68a616c88e4a7b19f5da29f79883c971 (diff) | |
download | bun-02cad591f8c56f801fb9ccc480bf9547484144c2.tar.gz bun-02cad591f8c56f801fb9ccc480bf9547484144c2.tar.zst bun-02cad591f8c56f801fb9ccc480bf9547484144c2.zip |
fix child process tests (#2584)
* always handle exit on next tick
* emit spawn immediately
-rw-r--r-- | src/bun.js/child_process.exports.js | 19 | ||||
-rw-r--r-- | test/js/node/child_process/child_process-node.test.js | 2 |
2 files changed, 8 insertions, 13 deletions
diff --git a/src/bun.js/child_process.exports.js b/src/bun.js/child_process.exports.js index 39f9380de..0ee72fe4c 100644 --- a/src/bun.js/child_process.exports.js +++ b/src/bun.js/child_process.exports.js @@ -1080,7 +1080,6 @@ export class ChildProcess extends EventEmitter { this.#encoding = options.encoding || undefined; this.#stdioOptions = bunStdio; - var hasEmittedSpawn = false; this.#handle = Bun.spawn({ cmd: spawnargs, stdin: bunStdio[0], @@ -1092,22 +1091,18 @@ export class ChildProcess extends EventEmitter { this.#handle = handle; this.pid = this.#handle.pid; - if (!hasEmittedSpawn) { - hasEmittedSpawn = true; - process.nextTick(onSpawnNT, this); - process.nextTick((exitCode, signalCode, err) => this.#handleOnExit(exitCode, signalCode, err)); - } else { - this.#handleOnExit(exitCode, signalCode, err); - } + process.nextTick( + (exitCode, signalCode, err) => this.#handleOnExit(exitCode, signalCode, err), + exitCode, + signalCode, + err, + ); }, lazy: true, }); this.pid = this.#handle.pid; - if (!hasEmittedSpawn) { - process.nextTick(onSpawnNT, this); - hasEmittedSpawn = true; - } + onSpawnNT(this); // const ipc = stdio.ipc; // const ipcFd = stdio.ipcFd; diff --git a/test/js/node/child_process/child_process-node.test.js b/test/js/node/child_process/child_process-node.test.js index a65906a43..f69b8668f 100644 --- a/test/js/node/child_process/child_process-node.test.js +++ b/test/js/node/child_process/child_process-node.test.js @@ -341,7 +341,7 @@ describe("child_process cwd", () => { ); }); - it.skip("shouldn't try to chdir to an invalid cwd", done => { + it("shouldn't try to chdir to an invalid cwd", done => { const createDone = createDoneDotAll(done); // Spawn() shouldn't try to chdir() to invalid arg, so this should just work testCwd({ cwd: "" }, { expectPidType: "number" }, createDone(1500)); |