Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs: fix async iterator partial writes with writeFile #38615

Closed

Conversation

Linkgoron
Copy link
Member

@Linkgoron Linkgoron commented May 9, 2021

Fix an issue where chunks might be partially written when using writeFile with an async iterator.

When writing a chunk it might only be partially written, as write is called without checking that everything was written - this fixes the issue. I've also added chunking to make the async iterator write match the regular write. There's a minor behaviour change, where previously strings would change to buffers in the c++ layer, however that made checking if the buffer was completely written extremely difficult, so I've moved it to the JS side (which is what happens in the non-iterator path as well).

fix an issue where chunks might be partially written when
using writeFile with an async iterator.
@github-actions github-actions bot added fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. labels May 9, 2021
@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

lib/internal/fs/promises.js Outdated Show resolved Hide resolved
@nodejs-github-bot

This comment has been minimized.

@Linkgoron Linkgoron added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 12, 2021
@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot
Copy link
Collaborator

nodejs-github-bot commented May 14, 2021

@jasnell
Copy link
Member

jasnell commented May 17, 2021

Landed in 3612229

@jasnell jasnell closed this May 17, 2021
jasnell pushed a commit that referenced this pull request May 17, 2021
fix an issue where chunks might be partially written when
using writeFile with an async iterator.

PR-URL: #38615
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit that referenced this pull request May 18, 2021
fix an issue where chunks might be partially written when
using writeFile with an async iterator.

PR-URL: #38615
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants