diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-07-22 18:07:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-22 18:07:20 +0200 |
commit | 72199303d899b8ddf2ff46ed11bd513ed9cc47e2 (patch) | |
tree | dc44930e29a070de4d0cf535d2958031c27345d1 /runtime/js | |
parent | 4db650ddd57b85475d71c0b9fc84d37becab9d6a (diff) |
fix: Child.unref() unrefs stdio streams properly (#15275)
Diffstat (limited to 'runtime/js')
-rw-r--r-- | runtime/js/40_spawn.js | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/runtime/js/40_spawn.js b/runtime/js/40_spawn.js index a00b8cfda..87db84f4b 100644 --- a/runtime/js/40_spawn.js +++ b/runtime/js/40_spawn.js @@ -75,6 +75,7 @@ class Child { #rid; #waitPromiseId; + #unrefed = false; #pid; get pid() { @@ -132,6 +133,7 @@ this.#stdoutRid = stdoutRid; this.#stdout = readableStreamForRid(stdoutRid, (promise) => { this.#stdoutPromiseId = promise[promiseIdSymbol]; + if (this.#unrefed) core.unrefOp(this.#stdoutPromiseId); }); } @@ -139,6 +141,7 @@ this.#stderrRid = stderrRid; this.#stderr = readableStreamForRid(stderrRid, (promise) => { this.#stderrPromiseId = promise[promiseIdSymbol]; + if (this.#unrefed) core.unrefOp(this.#stderrPromiseId); }); } @@ -204,12 +207,14 @@ } ref() { + this.#unrefed = false; core.refOp(this.#waitPromiseId); if (this.#stdoutPromiseId) core.refOp(this.#stdoutPromiseId); if (this.#stderrPromiseId) core.refOp(this.#stderrPromiseId); } unref() { + this.#unrefed = true; core.unrefOp(this.#waitPromiseId); if (this.#stdoutPromiseId) core.unrefOp(this.#stdoutPromiseId); if (this.#stderrPromiseId) core.unrefOp(this.#stderrPromiseId); |