-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
588 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
test/parallel/test-stream-pipeline-queued-end-in-destroy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
"use strict"; | ||
|
||
/*<replacement>*/ | ||
var bufferShim = require('safe-buffer').Buffer; | ||
/*</replacement>*/ | ||
|
||
|
||
var common = require('../common'); | ||
|
||
var assert = require('assert/'); | ||
|
||
var _require = require('../../'), | ||
Readable = _require.Readable, | ||
Duplex = _require.Duplex, | ||
pipeline = _require.pipeline; // Test that the callback for pipeline() is called even when the ._destroy() | ||
// method of the stream places an .end() request to itself that does not | ||
// get processed before the destruction of the stream (i.e. the 'close' event). | ||
// Refs: https://github.com/nodejs/node/issues/24456 | ||
|
||
|
||
var readable = new Readable({ | ||
read: common.mustCall(function () {}) | ||
}); | ||
var duplex = new Duplex({ | ||
write: function write(chunk, enc, cb) {// Simulate messages queueing up. | ||
}, | ||
read: function read() {}, | ||
destroy: function destroy(err, cb) { | ||
// Call end() from inside the destroy() method, like HTTP/2 streams | ||
// do at the time of writing. | ||
this.end(); | ||
cb(err); | ||
} | ||
}); | ||
duplex.on('finished', common.mustNotCall()); | ||
pipeline(readable, duplex, common.mustCall(function (err) { | ||
assert.strictEqual(err.code, 'ERR_STREAM_PREMATURE_CLOSE'); | ||
})); // Write one chunk of data, and destroy the stream later. | ||
// That should trigger the pipeline destruction. | ||
|
||
readable.push('foo'); | ||
setImmediate(function () { | ||
readable.destroy(); | ||
}); | ||
; | ||
|
||
require('tap').pass('sync run'); | ||
|
||
var _list = process.listeners('uncaughtException'); | ||
|
||
process.removeAllListeners('uncaughtException'); | ||
|
||
_list.pop(); | ||
|
||
_list.forEach(function (e) { | ||
return process.on('uncaughtException', e); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.