-
- Notifications
You must be signed in to change notification settings - Fork 33.7k
Closed
Labels
streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.
Description
- Version: master (e7ff00d)
- Platform: All
- Subsystem: stream
1e0f331 introduced an issue where the end event isn't emitted.
The following test case can reproduce it:
'use strict' const stream = require('stream') class ReadableArray extends stream.Readable { constructor(data) { super({ objectMode: true }) this._data = data } _read (size) { if (this._data.length === 0) return this.push(null); this.push(this._data.shift()); } } class PassThroughAsWrapper extends stream.Readable { constructor (readable) { super({ objectMode: true }) this._readable = readable this._readable.once('end', () => this.push(null)) } _read (size) { const data = this._readable.read() if (data === null) { this._readable.once('readable', () => { const data = this._readable.read() // this reads null, but somehow the end event is not emitted if (data !== null) return this.push(data) // end event handler will call .push() }) } else { return this.push(data) } } } const inputData = [{}, {}] const readable = new ReadableArray(inputData) let endEvent = false const result = new PassThroughAsWrapper( readable.pipe(new stream.PassThrough({ objectMode: true })) ) result.once('end', function () { endEvent = true; console.log('end event'); }) result.resume() process.on('exit', function () { if (!endEvent) console.log('no end event') })The expected result is end event the actual result is no end event.
/cc @mcollina @mafintosh
Metadata
Metadata
Assignees
Labels
streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.