GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fs: use correct position when retrying writev by christianaurichzm · Pull Request #66203 · nodejs/node

Conversation

@christianaurichzm

@christianaurichzm christianaurichzm commented Sep 22, 2026

Copy link
Copy Markdown
Member

WriteStream retries a partial writev() at the wrong position when start is set.

writevAll() tracks the next position in pos, but passes this.pos to writev(). _writev() advances this.pos by the full batch size before the callback runs, so a short write can retry from the end of the batch instead of after the bytes that were written.

For a 12-byte batch starting at 0, with the first call writing 3 bytes:

writev at 0
writev at 12

The second call should be at 3. The current result is:

"AAA\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000ABBBBCCCC"

EAGAIN has the same problem: the retry uses the advanced this.pos even though no bytes were written.

Pass pos instead, matching writeAll().

The regression test covers partial writes at start: 0 and start: 5, EAGAIN, and the unpositioned case.

For start: 5:

partial write: [5, 17] -> [5, 8]
EAGAIN:        [5, 17] -> [5, 5]

make lint passes. parallel and sequential were also run on Linux x64. Four parallel failures related to --use-openssl-ca also reproduce on the base commit.

Refs: #49211

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@christianaurichzm
fs: use correct position when retrying writev
f6535a4
writevAll() tracks the position for the next attempt in its `pos`
argument, but calls fs.writev() with `this.pos`. WriteStream._writev()
advances `this.pos` by the whole batch right after starting the write,
so a retry from the asynchronous callback resumes at the end of the
batch instead of after the bytes that reached the file. A partial write
leaves a hole and puts the remainder past its place; an EAGAIN retry
moves forward even though nothing was written.

Use the local `pos`, as writeAll() already does.

Signed-off-by: Christian Aurich Zanettini Martins <[email protected]>
@nodejs-github-bot nodejs-github-bot added fs Issues and PRs related to file-system APIs and the fs module. needs-ci PRs that need a full CI run. labels Sep 22, 2026
@codecov

codecov Bot commented Sep 22, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.29%. Comparing base (36dd044) to head (f6535a4).
⚠️ Report is 907 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #66203   +/-   ##
=======================================
  Coverage   90.29%   90.29%           
=======================================
  Files         790      790           
  Lines      272529   272529           
  Branches    52031    52033    +2     
=======================================
+ Hits       246083   246089    +6     
+ Misses      16909    16897   -12     
- Partials     9537     9543    +6     
Files with missing lines Coverage Δ
lib/internal/fs/streams.js 94.45% <100.00%> (+1.34%) ⬆️

... and 26 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@christianaurichzm

christianaurichzm commented Oct 6, 2026

Copy link
Copy Markdown
Member Author

@atlowChemi since you finished writevAll() in #49211, could you take a look at this one-line fix when you get a chance? cc @lpinca. If it looks good, could you also add request-ci? Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@christianaurichzm

christianaurichzm commented Oct 12, 2026

Copy link
Copy Markdown
Member Author

@ronag, since writevAll() comes from your feb5b0f, could you take a look at this when you get a chance? It passes this.pos instead of the local pos, so a short writev() is retried past the bytes that were actually written. cc @panva. If it looks good, could you also add request-ci? Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@christianaurichzm
christianaurichzm requested a review from lpinca November 13, 2026 14:14
@lpinca lpinca added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 13, 2026
@nodejs-github-bot

nodejs-github-bot commented Nov 14, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/79082/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@christianaurichzm christianaurichzm removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 14, 2026
ronag
ronag approved these changes Nov 14, 2026
View reviewed changes
@ronag ronag added author ready PRs with CI started, the required approvals, and no outstanding review comments. request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. labels Nov 14, 2026
@ronag
ronag requested a review from mcollina November 14, 2026 20:18
mcollina
mcollina approved these changes Nov 14, 2026
View reviewed changes

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@github-actions github-actions Bot added request-ci-failed Starting CI with the request-ci label failed and requires manual intervention. and removed request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. labels Nov 14, 2026
@github-actions

github-actions Bot commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Failed to start CI

   ℹ  Existing CI run found: https://ci.nodejs.org/job/node-test-pull-request/79082/
   ✖  Refusing to start a potentially duplicate CI job. The existing CI run is still in progress.
Full Auto Start CI output
�[36m⠋�[39m Getting reviews from nodejs/node/pull/66203
�[36m⠋�[39m Getting commits from nodejs/node/pull/66203
�[36m⠙�[39m Validating Jenkins credentials
�[36m⠙�[39m Validating Jenkins credentials
✔  Jenkins credentials valid
�[36m⠹�[39m Getting comments from nodejs/node/pull/66203
�[36m⠸�[39m Querying data for job/node-test-pull-request/79082/
�[36m⠸�[39m Querying data for job/node-test-pull-request/79082/
�[36m⠸�[39m Querying API for job/node-test-pull-request/79082/
✔  Build data downloaded
   ℹ  Existing CI run found: https://ci.nodejs.org/job/node-test-pull-request/79082/
   ✖  Refusing to start a potentially duplicate CI job. The existing CI run is still in progress.

View workflow run

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@christianaurichzm christianaurichzm added resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. and removed request-ci-failed Starting CI with the request-ci label failed and requires manual intervention. resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. labels Nov 14, 2026
@github-actions github-actions Bot removed the resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. label Nov 14, 2026
@nodejs-github-bot

nodejs-github-bot commented Nov 14, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/79098/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@christianaurichzm christianaurichzm added the resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. label Nov 15, 2026
@github-actions github-actions Bot removed the resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. label Nov 15, 2026
@nodejs-github-bot

nodejs-github-bot commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/79103/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@christianaurichzm christianaurichzm added the commit-queue PRs queued for automated landing through the Commit Queue. label Nov 15, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 2e59a6d into nodejs:main Nov 15, 2026
96 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator

Landed in 2e59a6d

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Nov 15, 2026
aduh95 pushed a commit that referenced this pull request Nov 19, 2026
@christianaurichzm @aduh95
fs: use correct position when retrying writev
56bc6f0
writevAll() tracks the position for the next attempt in its `pos`
argument, but calls fs.writev() with `this.pos`. WriteStream._writev()
advances `this.pos` by the whole batch right after starting the write,
so a retry from the asynchronous callback resumes at the end of the
batch instead of after the bytes that reached the file. A partial write
leaves a hole and puts the remainder past its place; an EAGAIN retry
moves forward even though nothing was written.

Use the local `pos`, as writeAll() already does.

Signed-off-by: Christian Aurich Zanettini Martins <[email protected]>
PR-URL: #66203
Refs: #49211
Reviewed-By: Robert Nagy <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
james-pre added a commit to zen-fs/core that referenced this pull request Nov 23, 2026
@james-pre
Fixed stream writes dropping data after short write (nodejs/node#66203)
ebb628a
@github-actions github-actions Bot mentioned this pull request Nov 24, 2026
2026-11-25, Version 27.0.0-alpha.0.2.0 (Alpha) #67757
Merged
gabylb pushed a commit to gabylb/node that referenced this pull request Nov 27, 2026
@christianaurichzm @gabylb
fs: use correct position when retrying writev
e07b43e
writevAll() tracks the position for the next attempt in its `pos`
argument, but calls fs.writev() with `this.pos`. WriteStream._writev()
advances `this.pos` by the whole batch right after starting the write,
so a retry from the asynchronous callback resumes at the end of the
batch instead of after the bytes that reached the file. A partial write
leaves a hole and puts the remainder past its place; an EAGAIN retry
moves forward even though nothing was written.

Use the local `pos`, as writeAll() already does.

Signed-off-by: Christian Aurich Zanettini Martins <[email protected]>
PR-URL: nodejs#66203
Refs: nodejs#49211
Reviewed-By: Robert Nagy <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@mcollina mcollina mcollina approved these changes
@ronag ronag ronag approved these changes
@lpinca lpinca Awaiting requested review from lpinca

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. fs Issues and PRs related to file-system APIs and the fs module. needs-ci PRs that need a full CI run.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@christianaurichzm @nodejs-github-bot @mcollina @ronag @lpinca
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.