Skip to content

Commit 126dd80

Browse files
committed
fixup
1 parent bbdf58e commit 126dd80

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

lib/_http_server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ function resOnFinish(req, res, socket, state, server) {
803803
// If the user never called req.read(), and didn't pipe() or
804804
// .resume() or .on('data'), then we call req._dump() so that the
805805
// bytes will be pulled off the wire.
806-
if (!req._consuming && !req._readableState.resumeScheduled)
806+
if (!req.readableDidRead)
807807
req._dump();
808808

809809
// Make sure the requestTimeout is cleared before finishing.

lib/internal/streams/readable.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ function Readable(options) {
205205
Stream.call(this, options);
206206

207207
destroyImpl.construct(this, () => {
208-
if (this._readableState.didRead) {
208+
if (this._readableState.needReadable) {
209209
maybeReadMore(this, this._readableState);
210210
}
211211
});
@@ -405,8 +405,6 @@ Readable.prototype.read = function(n) {
405405
const state = this._readableState;
406406
const nOrig = n;
407407

408-
state.didRead = true;
409-
410408
// If we're asking for more than the current hwm, then raise the hwm.
411409
if (n > state.highWaterMark)
412410
state.highWaterMark = computeNewHighWaterMark(n);
@@ -486,6 +484,7 @@ Readable.prototype.read = function(n) {
486484
// If the length is currently zero, then we *need* a readable event.
487485
if (state.length === 0)
488486
state.needReadable = true;
487+
489488
// Call internal read method
490489
this._read(state.highWaterMark);
491490
state.sync = false;
@@ -524,8 +523,10 @@ Readable.prototype.read = function(n) {
524523
endReadable(this);
525524
}
526525

527-
if (ret !== null)
526+
if (ret !== null) {
527+
state.didRead = true;
528528
this.emit('data', ret);
529+
}
529530

530531
return ret;
531532
};
@@ -976,6 +977,7 @@ Readable.prototype.resume = function() {
976977
function resume(stream, state) {
977978
if (!state.resumeScheduled) {
978979
state.resumeScheduled = true;
980+
state.didRead = true;
979981
process.nextTick(resume_, stream, state);
980982
}
981983
}

test/parallel/test-stream-readable-data.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
'use strict';
22
const common = require('../common');
3-
const assert = require('assert');
43

54
const { Readable } = require('stream');
65

76
const readable = new Readable({
8-
read() {
9-
assert.strictEqual(readable.readableDidRead, true);
10-
}
7+
read() {}
118
});
12-
assert.strictEqual(readable.readableDidRead, false);
139

1410
function read() {}
1511

0 commit comments

Comments
 (0)