Closed
Description
I ran into edge case while working on Vitest. Unfortunately I was unable to create minimal reproduction. Reproduction with Vitest: AriPerkkio/vitest@de3dc71
When we add exit
listener that calls process.exit
inside it, Tinyexec loses stdout
from that process. This is similar exit handling as tinylibs/picospinner
does.
It seems that subprocess.stdout
returned from node:child_process.spawn
is closed when subprocess.stderr
is read. Here's some logging from Vitest's case:
Lines 216 to 226 in 24e9861
+ console.log('before', this._streamOut?.closed);
+ // > before false
if (this._streamErr) {
for await (const chunk of this._streamErr) {
stderr += chunk.toString();
}
}
+ console.log('after', this._streamOut?.closed);
+ // > after true
if (this._streamOut) {
for await (const chunk of this._streamOut) {
stdout += chunk.toString();
}
}
To fix these, we'll need to first read stdout
.
Replacing tinyexec
with node:child_process.execSync
works 100% times.
Metadata
Metadata
Assignees
Labels
No labels