Skip to content

[REG 18.10.0->18.11.0] fs.promises.readFile from stdin is broken for slow input #52155

@orgads

Description

@orgads

Version

18.11.0-18.19.0, 20.11.1

Platform

Linux

Subsystem

fs

What steps will reproduce the bug?

$ (echo -n '{'; sleep 1; echo -n '}') | docker run --rm -i node:18.10.0-alpine -e "const fs = require('fs/promises'); fs.readFile('/dev/stdin').then((data) => console.log(data.length))"
2
$ (echo -n '{'; sleep 1; echo -n '}') | docker run --rm -i node:18.11.0-alpine -e "const fs = require('fs/promises'); fs.readFile('/dev/stdin').then((data) => console.log(data.length))"
1

Reproducible also without docker:

$ (echo -n '{'; sleep 1; echo -n '}') | node -e "const fs = require('fs/promises'); fs.readFile('/dev/stdin').then((data) => console.log(data.length))"
1

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

Always.

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

It should read stdin until EOF is reached.

What do you see instead?

It stops too early.

Additional information

This was broken by 67fb765 (and its other versions in the other branches).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions