Skip to content

fs/promises's readFile returns truncated content for files in /proc/net/ #50437

@notcake

Description

@notcake

Version

v21.1.0

Platform

Linux ubuntu 6.2.0-35-generic #35~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Oct 6 10:23:26 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

fs/promises

What steps will reproduce the bug?

Compare the length of the content returned by fs/promises.readFile and fs.readFile when reading any file larger than 4 KiB in /proc/net. fs/promises only returns the first 4 KiB or so.

$ node
Welcome to Node.js v21.1.0.
Type ".help" for more information.
> require("fs/promises").readFile("/proc/net/unix", "utf-8").then(x => console.log(x.length))
Promise {
  <pending>,
  [Symbol(async_id_symbol)]: 31,
  [Symbol(trigger_async_id_symbol)]: 25
}
> 4059
require("fs").readFile("/proc/net/unix", "utf-8", (_, x) => console.log(x.length))
undefined
> 65432

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

Always

What is the expected behavior? Why is that the expected behavior?

fs/promises's readFile and fs.readFile return the same untruncated file contents.

What do you see instead?

fs/promises's readFile truncates procfs file contents to around 4 KiB.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.fsIssues and PRs related to the fs subsystem / file system.linuxIssues and PRs related to the Linux platform.promisesIssues and PRs related to ECMAScript promises.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions