fix(test): drain session-event-log writes before rmSync cleanup in save-script transport tests - #1999
Merged
Conversation
The save-script transport tests' afterEach removed the per-test temp root while a fire-and-forget session-event-log append (queued by every request the tests send) could still be in flight. Under coverage-shard load the append re-created the session dir between rmSync's unlink sweep and its rmdir, failing cleanup with ENOTEMPTY. Await flushSessionEventLogWrites() before removing the roots. Closes #1998
Size Report
npm unpacked components
Startup median (7 runs, lower is better):
Top changed chunks: no changes in the largest emitted chunks. Top changed packed filesNo changed packed files. |
Member
Author
|
Reviewed exact head |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the pre-existing flake documented in #1996 ("Known pre-existing flake") and analyzed in #1998:
request-save-script-transports.test.tshitENOTEMPTYin its ownafterEachunder coverage-shard load.Every request the tests send queues a fire-and-forget session-event-log append (
queueEventLogWrite: unawaitedmkdir -p→ rotate →appendFileintosessions/<session>/events.ndjson). The daemon response resolves before the write lands, so under load a pending append could re-create the session dir betweenrmSync's unlink sweep and its rmdir — cleanup then fails withENOTEMPTY.The fix awaits the existing quiesce hook,
flushSessionEventLogWrites(), at the top of theafterEachbefore removing the temp roots. One line plus the import.Closes #1998
Validation
pnpm vitest run src/daemon/__tests__/request-save-script-transports.test.ts— 8/8 green, six consecutive runs.pnpm format:check,pnpm lint,pnpm typecheckclean.The race itself is timing-dependent (one occurrence on a loaded shard), so the runs above show no regression rather than proving the flake gone; the flush removes the ordering hazard by construction. #1998 notes the wider sweep (other daemon tests that drive
createRequestHandlerthenrmSynca temp root) as follow-up.