| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8584068 commit 7612574
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -494,6 +494,7 @@ Readable.prototype.read = function(n) { | |||
| 494 | 494 | }; | |
| 495 | 495 | ||
| 496 | 496 | function onEofChunk(stream, state) { | |
| 497 | + debug('onEofChunk'); | ||
| 497 | 498 | if (state.ended) return; | |
| 498 | 499 | if (state.decoder) { | |
| 499 | 500 | var chunk = state.decoder.end(); | |
@@ -524,6 +525,7 @@ function onEofChunk(stream, state) { | |||
| 524 | 525 | // a nextTick recursion warning, but that's not so bad. | |
| 525 | 526 | function emitReadable(stream) { | |
| 526 | 527 | var state = stream._readableState; | |
| 528 | + debug('emitReadable', state.needReadable, state.emittedReadable); | ||
| 527 | 529 | state.needReadable = false; | |
| 528 | 530 | if (!state.emittedReadable) { | |
| 529 | 531 | debug('emitReadable', state.flowing); | |
@@ -537,6 +539,7 @@ function emitReadable_(stream) { | |||
| 537 | 539 | debug('emitReadable_', state.destroyed, state.length, state.ended); | |
| 538 | 540 | if (!state.destroyed && (state.length || state.ended)) { | |
| 539 | 541 | stream.emit('readable'); | |
| 542 | + state.emittedReadable = false; | ||
| 540 | 543 | } | |
| 541 | 544 | ||
| 542 | 545 | // The stream needs another readable event if | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,32 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const assert = require('assert'); | ||
| 5 | + const { Readable } = require('stream'); | ||
| 6 | + | ||
| 7 | + const buf = Buffer.alloc(8192); | ||
| 8 | + | ||
| 9 | + const readable = new Readable({ | ||
| 10 | + read: common.mustCall(function() { | ||
| 11 | + this.push(buf); | ||
| 12 | + }, 31) | ||
| 13 | + }); | ||
| 14 | + | ||
| 15 | + let i = 0; | ||
| 16 | + | ||
| 17 | + readable.on('readable', common.mustCall(function() { | ||
| 18 | + if (i++ === 10) { | ||
| 19 | + // We will just terminate now. | ||
| 20 | + process.removeAllListeners('readable'); | ||
| 21 | + return; | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + const data = readable.read(); | ||
| 25 | + // TODO(mcollina): there is something odd in the highWaterMark logic | ||
| 26 | + // investigate. | ||
| 27 | + if (i === 1) { | ||
| 28 | + assert.strictEqual(data.length, 8192 * 2); | ||
| 29 | + } else { | ||
| 30 | + assert.strictEqual(data.length, 8192 * 3); | ||
| 31 | + } | ||
| 32 | + }, 11)); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments