diff options
Diffstat (limited to 'src/bun.js/builtins/js/ProcessObjectInternals.js')
-rw-r--r-- | src/bun.js/builtins/js/ProcessObjectInternals.js | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/bun.js/builtins/js/ProcessObjectInternals.js b/src/bun.js/builtins/js/ProcessObjectInternals.js index 5c5fab9ea..87bb07b95 100644 --- a/src/bun.js/builtins/js/ProcessObjectInternals.js +++ b/src/bun.js/builtins/js/ProcessObjectInternals.js @@ -534,20 +534,26 @@ function getStdinStream(fd, rawRequire, Bun) { } } - _read(size) { - this.#reader.read().then((data) => { - if (data.done) { + async #readInternal() { + try { + const { done, value } = await this.#reader.read(); + + if (!done) { + this.push(value); + } else { this.push(null); this.pause(); this.#readable = false; this.#onFinished(); - } else { - this.push(data.value); } - }).catch((err) => { + } catch (err) { this.#readable = false; this.#onFinished(err); - }); + } + } + + _read(size) { + this.#readInternal(); } #constructWriteStream() { |