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

Function onDestroy

lib/internal/streams/destroy.js:93–120  ·  view source on GitHub ↗
(err)

Source from the content-addressed store, hash-verified

91 let called = false;
92
93 function onDestroy(err) {
94 if (called) {
95 return;
96 }
97 called = true;
98
99 const r = self._readableState;
100 const w = self._writableState;
101
102 checkError(err, w, r);
103
104 if (w) {
105 w[kState] |= kClosed;
106 }
107 if (r) {
108 r[kState] |= kClosed;
109 }
110
111 if (typeof cb === 'function') {
112 cb(err);
113 }
114
115 if (err) {
116 process.nextTick(emitErrorCloseNT, self, err);
117 } else {
118 process.nextTick(emitCloseNT, self);
119 }
120 }
121 try {
122 self._destroy(err || null, onDestroy);
123 } catch (err) {

Callers 1

_destroyFunction · 0.85

Calls 2

checkErrorFunction · 0.70
cbFunction · 0.70

Tested by

no test coverage detected