Skip to content

Nonsense UNKNOWN error when writing large buffers with fs.writev #40779

Description

@zbjornson

Version

14.18.1

Platform

Linux ops 5.11.0-1021-gcp #23~20.04.1-Ubuntu SMP Fri Oct 1 19:04:32 UTC 2021 x86_64 x86_64 x86_64 GNU/Linu

Subsystem

fs

What steps will reproduce the bug?

const fs = require("fs");
const fd = fs.openSync("./test.dat", fs.constants.O_WRONLY | fs.constants.O_CREAT, 0o666);
const bufs = [Buffer.alloc(0x7FFFFFFF + 1)];
fs.writevSync(fd, bufs, 0);

This throws

Uncaught Error: UNKNOWN: unknown error, write
    at Object.writevSync (fs.js:749:3) {
  errno: -2147483648,
  syscall: 'write',
  code: 'UNKNOWN'
}

That errno is 0x7fffffff + 1 wrapped around.

How often does it reproduce? Is there a required condition?

Always.

What is the expected behavior?

Should either work, since pwritev(2) works (I don't know if it has a limit less than SSIZE_MAX), or report a proper error before making the syscall. I did the latter recently for fs.write in c4e7dca. It would be nice if large files actually worked, but the best fix for that would require a new libuv function.

What do you see instead?

No response

Additional information

No response

Activity

  1. added
    fsIssues and PRs related to file-system APIs and the fs module.
    on Nov 10, 2021
  2. github-actions commented on Jun 26, 2026

    @github-actions
    Contributor

    This issue has been marked as stale due to 210 days of inactivity.
    It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.

  3. added
    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.
    on Jun 26, 2026
  4. zbjornson commented on Jun 27, 2026

    @zbjornson
    ContributorAuthor

    Still relevant, and I see related upstream activity in libuv in March!

  5. removed
    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.
    on Jun 27, 2026
  6. github-actions commented on Sep 26, 2026

    @github-actions
    Contributor

    This issue has been marked as stale due to 90 days of inactivity.
    It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.

  7. added
    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.
    on Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    fsIssues and PRs related to file-system APIs and the fs module.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions