fix(svelte-check): flush stdout/stderr before exit#3014
Merged
jasonlyu123 merged 3 commits intosveltejs:masterfrom May 1, 2026
Merged
fix(svelte-check): flush stdout/stderr before exit#3014jasonlyu123 merged 3 commits intosveltejs:masterfrom
jasonlyu123 merged 3 commits intosveltejs:masterfrom
Conversation
`process.stdout.write` is asynchronous on non-TTY pipes, and per Node's docs `process.exit` does not wait for queued I/O. Under heavy diagnostic load (1000+ ERROR/WARNING lines, enough to saturate the kernel pipe buffer) the trailing `COMPLETED` summary of `--output machine-verbose` was dropped when the CLI exited, even though the run was clean. Replace the bare `process.exit(N)` calls in both CLI completion paths (default and `useVirtualFiles`) with the canonical flush-then-exit pattern. Add a regression test `test-flush.js` (`pnpm run test:flush`) that runs the CLI against a fixture emitting 1500 diagnostics, throttles the consumer to keep the pipe full, and asserts the last non-empty line matches `^\d+ COMPLETED` across 10 runs. This is useful for testing this fix but I don't know if it's worth actually commiting it to the repo or not. `test-flush.js` is AI generated and manually reviewed.
🦋 Changeset detectedLatest commit: 4d40adb The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Member
|
Thanks you. I removed the test from the build script since it already serves the verification purpose, and it's unlikely to break in the future. Still keeping the test file so we can run it manually. |
Merged
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.
Resolves: #3013
process.stdout.writeis asynchronous on non-TTY pipes, and per Node's docsprocess.exitdoes not wait for queued I/O. Under heavy diagnostic load (1000+ ERROR/WARNING lines, enough to saturate the kernel pipe buffer) the trailingCOMPLETEDsummary of--output machine-verbosewas dropped when the CLI exited, even though the run was clean.Replace the bare
process.exit(N)calls in both CLI completion paths (default anduseVirtualFiles) with the canonical flush-then-exit pattern.Add a regression test
test-flush.js(pnpm run test:flush) that runs the CLI against a fixture emitting 1500 diagnostics, throttles the consumer to keep the pipe full, and asserts the last non-empty line matches^\d+ COMPLETEDacross 10 runs. This is useful for testing this fix but I don't know if it's worth actually commiting it to the repo or not.test-flush.jsis AI generated and manually reviewed.