MCPcopy Index your code
hub / github.com/nodejs/node / _destroy

Method _destroy

lib/internal/streams/duplexpair.js:55–76  ·  view source on GitHub ↗
(err, callback)

Source from the content-addressed store, hash-verified

53
54
55 _destroy(err, callback) {
56 const otherSide = this.#otherSide;
57
58 if (otherSide !== null && !otherSide.destroyed) {
59 // Use nextTick to avoid crashing the current execution stack (like HTTP parser)
60 process.nextTick(() => {
61 if (otherSide.destroyed) return;
62
63 if (err) {
64 // Destroy the other side, without passing the 'err' object.
65 // This closes the other side gracefully so it doesn't hang,
66 // but prevents the "Unhandled error" crash.
67 otherSide.destroy();
68 } else {
69 // Standard graceful close
70 otherSide.push(null);
71 }
72 });
73 }
74
75 callback(err);
76 }
77}
78
79function duplexPair(options) {

Callers 1

_destroyFunction · 0.45

Calls 3

callbackFunction · 0.50
destroyMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected