Skip to content

Readable Pause event not triggered when unpipe causes the pause #32470

Closed
@casret

Description

@casret
  • Version: v12.16.1 v13.9.0
  • Platform: Darwin *** 19.2.0 Darwin Kernel Version 19.2.0: Sat Nov 9 03:47:04 PST 2019; root:xnu-6153.61.1~20/RELEASE_X86_64 x86_64 i386 MacBookPro14,1 Darwin
  • Subsystem: stream

What steps will reproduce the bug?

const fs = require('fs');
const readable = fs.createReadStream("in")
const writable = fs.createWriteStream('out')
readable.on("resume", () => console.log("resume called"))
readable.on("pause", () => console.log("pause called"))
console.log(readable.isPaused())
readable.pipe(writable);
console.log(readable.isPaused())
readable.unpipe(writable);
console.log(readable.isPaused())

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

Every time.

What is the expected behavior?

I would expect the pause event to occur (and "pause called" to be written to the console).

What do you see instead?

Nothing

Additional information

Though the docs say that pause will be emitted when pause() is called, it also says that about the resume event, but the resume event is emitted on first pipe(), so it's inconsistent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    streamIssues and PRs related to the stream subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions