summaryrefslogtreecommitdiff
path: root/lib/internal/streams/destroy.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/internal/streams/destroy.js')
-rw-r--r--lib/internal/streams/destroy.js13
1 files changed, 1 insertions, 12 deletions
diff --git a/lib/internal/streams/destroy.js b/lib/internal/streams/destroy.js
index 8708ca022c..27985482ce 100644
--- a/lib/internal/streams/destroy.js
+++ b/lib/internal/streams/destroy.js
@@ -27,10 +27,6 @@ function destroy(err, cb) {
const r = this._readableState;
const w = this._writableState;
- if (w && err) {
- w.errored = true;
- }
-
if ((w && w.destroyed) || (r && r.destroyed)) {
if (cb) {
cb(err);
@@ -54,12 +50,10 @@ function destroy(err, cb) {
this._destroy(err || null, (err) => {
const emitClose = (w && w.emitClose) || (r && r.emitClose);
if (cb) {
- // Invoke callback before scheduling emitClose so that callback
- // can schedule before.
- cb(err);
if (emitClose) {
process.nextTick(emitCloseNT, this);
}
+ cb(err);
} else if (needError(this, err)) {
process.nextTick(emitClose ? emitErrorCloseNT : emitErrorNT, this, err);
} else if (emitClose) {
@@ -97,7 +91,6 @@ function undestroy() {
if (w) {
w.destroyed = false;
- w.errored = false;
w.ended = false;
w.ending = false;
w.finalCalled = false;
@@ -117,10 +110,6 @@ function errorOrDestroy(stream, err) {
const r = stream._readableState;
const w = stream._writableState;
- if (w & err) {
- w.errored = true;
- }
-
if ((r && r.autoDestroy) || (w && w.autoDestroy))
stream.destroy(err);
else if (needError(stream, err))