files: await pending stream writes before closing the handle - #337018
Merged
Christof Marti (chrmarti) merged 2 commits intoSep 21, 2026
Merged
Christof Marti (chrmarti) merged 2 commits into
Christof Marti (chrmarti) merged 2 commits into
Conversation
Wait for buffered stream writes on end and error so the provider handle remains open and late write errors are propagated. Cover success, write failure, and stream failure with deferred-write regression tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot started reviewing on behalf of
Christof Marti (chrmarti)
September 21, 2026 11:04
View session
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The narrow lifecycle fix correctly preserves write errors and handle ordering with focused regression coverage.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes a file-service race by waiting for asynchronous stream writes before closing provider handles.
Changes:
- Serializes pending buffered writes and delays stream settlement.
- Prevents resuming completed or failed streams.
- Adds regression tests for success, write failure, and stream failure.
| File | Description |
|---|---|
src/vs/platform/files/common/fileService.ts |
Awaits pending writes before resolving or rejecting. |
src/vs/platform/files/test/browser/fileService.test.ts |
Adds deterministic stream-write race coverage. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Use one completion handler for stream end, stream error, and write failure. Wait for pending writes without replacing an earlier stream error, and cover combined stream/write failures. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Christof Marti (chrmarti)
marked this pull request as ready for review
September 21, 2026 13:09
Christof Marti (chrmarti)
enabled auto-merge (squash)
September 21, 2026 13:09
Benjamin Christopher Simmonds (benibenj)
approved these changes
Sep 21, 2026
Christof Marti (chrmarti)
deleted the
chrmarti/fix-buffered-stream-write-completion
branch
September 21, 2026 13:32
Christof Marti (chrmarti)
added a commit
that referenced
this pull request
Sep 21, 2026
Add regression coverage for buffered chunk serialization, partial writes, producer backpressure, peeked prefixes, empty streams, and queued writes following provider or stream failures. Follow up on #337018 without changing production code. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
Fix the buffered file-write race behind the macOS / Electron failure on #336992.
A stream can emit
endorerrorwhile its asynchronousonDatawrite is still pending.FileServicepreviously settled the stream operation immediately and closed the provider handle before the write finished. This can leave the disk provider retrying a write against a closed handle, and can incorrectly report success when the pending write subsequently fails.The CI log reports two teardown failures under
ExtHostAuthentication / createIfNone - false, but the leaked cancellation listeners originate in the preceding file-service work (doWriteBuffer-> disk write retry -> timeout). The second failure is the console-output guard reacting to the leak report. The notebook-only changes in #336992 are unrelated.Changes
Incoming PR check
No overlapping fix found. In particular:
Validation
npm run gulp compile-client: 0 errors.git diff --check, and commit hygiene: passed.Local validation was on Windows. macOS-specific confirmation is left to PR CI.