Skip to content

fix: preserve output for repeated awaits - #195

Merged
43081j merged 1 commit into
tinylibs:mainfrom
fbirds5230:fix/cache-awaited-output
Nov 24, 2026
Merged

43081j merged 1 commit into
tinylibs:mainfrom
fbirds5230:fix/cache-awaited-output

Conversation

@fbirds5230

Copy link
Copy Markdown
Contributor

Awaiting a tinyexec result more than once currently reads stdout and stderr again, so the second await returns empty strings. Two .then() handlers attached before completion can also compete for the same output.

Keep one output promise per spawned process and attach each handler to it. This preserves the captured output and rejection for later awaiters while keeping the handlers' chained results independent. spawn() clears the cached promise so reusing an ExecProcess reads the new process's output.

The regression tests cover repeated awaits, concurrent handlers, failures with captured output, and explicit respawning. The first three fail before the fix.

Validation on Linux:

  • npm test: build succeeds; 60 tests pass with 10 existing skips on Node 24.22.3.
  • Full unit suite on Node 22.18.0: 60 pass with the same 10 skips.
  • npm run lint (TypeScript, ESLint and publint).
  • npm run format:check.

@43081j
43081j merged commit 488f3e7 into tinylibs:main Nov 24, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants