Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stream] : Readable (flowing mode) does not start with pause at true #56677

Open
Necrelox opened this issue Jan 21, 2025 · 2 comments
Open

[stream] : Readable (flowing mode) does not start with pause at true #56677

Necrelox opened this issue Jan 21, 2025 · 2 comments
Labels
stream Issues and PRs related to the stream subsystem.

Comments

@Necrelox
Copy link

Necrelox commented Jan 21, 2025

Version

v23.6.0

Platform

6.12.10-arch1-1 #1 SMP PREEMPT_DYNAMIC Sat, 18 Jan 2025 02:26:57 +0000 x86_64 GNU/Linux

Subsystem

stream

What steps will reproduce the bug?

import { Readable } from 'stream';

const readable = new Readable({
    read(): void {
        this.push('foo');
        this.push('bar');
        this.push(null);
    }
});

console.log('isPaused :', readable.isPaused()); // print => false

readable.on('data', (chunk) => {
    console.log(chunk);
});

console.log('isPaused :', readable.isPaused()); // print => false

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

always

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

I think the first console.log('isPaused:', readable.isPaused()); should return true, as mentioned on the documentation :

All Readable streams begin in paused mode but can be switched to flowing mode in one of the following ways:

What do you see instead?

The problem is that the first console.log('isPaused:', readable.isPaused()); returns false
Is this an error on my part? or a misunderstanding?

Additional information

No response

@VoltrexKeyva VoltrexKeyva added the stream Issues and PRs related to the stream subsystem. label Jan 21, 2025
@lpinca
Copy link
Member

lpinca commented Jan 21, 2025

See https://nodejs.org/api/stream.html#three-states. When readable.readableFlowing === null the stream is not paused.

@Necrelox
Copy link
Author

I'm sorry, I stopped before 😭, Looking closely at the documentation example actually

const readable = new stream.Readable();

readable.isPaused(); // === false
readable.pause();
readable.isPaused(); // === true
readable.resume();
readable.isPaused(); // === false 

But it says :

The readable.isPaused() method returns the current operating state of the Readable

I don't really understand why there's an isPaused()

In any case, thank you very much, I'm really sorry I missed it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stream Issues and PRs related to the stream subsystem.
Projects
None yet
Development

No branches or pull requests

3 participants