Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup: pasued
  • Loading branch information
ronag committed Dec 21, 2019
commit 2a2782644cb3c41c2f23ab0bda3018db1449ff51
6 changes: 3 additions & 3 deletions lib/_stream_readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function ReadableState(options, stream, isDuplex) {
this.emittedReadable = false;
this.readableListening = false;
this.resumeScheduled = false;
this.paused = true;
this.paused = null;
Comment thread
ronag marked this conversation as resolved.
Outdated

// True if the error was already emitted and should not be thrown again
this.errorEmitted = false;
Expand Down Expand Up @@ -368,7 +368,7 @@ function chunkInvalid(state, chunk) {


Readable.prototype.isPaused = function() {
return this._readableState.flowing === false;
return this._readableState.paused === true;
};

// Backwards compatibility.
Expand Down Expand Up @@ -967,7 +967,7 @@ function updateReadableListening(self) {
const state = self._readableState;
state.readableListening = self.listenerCount('readable') > 0;

if (state.resumeScheduled && !state.paused) {
if (state.resumeScheduled && state.paused === false) {
// Flowing needs to be set to true now, otherwise
// the upcoming resume will not flow.
state.flowing = true;
Expand Down
18 changes: 18 additions & 0 deletions test/parallel/test-stream-readable-pause-and-resume.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const common = require('../common');
const assert = require('assert');
const { Readable } = require('stream');

let ticks = 18;
Expand Down Expand Up @@ -38,3 +39,20 @@ function readAndPause() {

rs.on('data', ondata);
}

{
const readable = new Readable({
read() {}
});

function read() {}

readable.setEncoding('utf8');
readable.on('readable', read);
readable.removeListener('readable', read);
readable.pause();

process.nextTick(function() {
assert(readable.isPaused()); // Throws.
});
}