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

Function destroyer

lib/internal/streams/destroy.js:322–353  ·  view source on GitHub ↗
(stream, err)

Source from the content-addressed store, hash-verified

320
321// Normalize destroy for legacy.
322function destroyer(stream, err) {
323 if (!stream || isDestroyed(stream)) {
324 return;
325 }
326
327 if (!err && !isFinished(stream)) {
328 err = new AbortError();
329 }
330
331 // TODO: Remove isRequest branches.
332 if (isServerRequest(stream)) {
333 stream.socket = null;
334 stream.destroy(err);
335 } else if (isRequest(stream)) {
336 stream.abort();
337 } else if (isRequest(stream.req)) {
338 stream.req.abort();
339 } else if (typeof stream.destroy === 'function') {
340 stream.destroy(err);
341 } else if (typeof stream.close === 'function') {
342 // TODO: Don't lose err?
343 stream.close();
344 } else if (err) {
345 process.nextTick(emitErrorCloseLegacy, stream, err);
346 } else {
347 process.nextTick(emitCloseLegacy, stream);
348 }
349
350 if (!stream.destroyed) {
351 stream[kIsDestroyed] = true;
352 }
353}
354
355module.exports = {
356 construct,

Callers 3

compose.jsFile · 0.70
duplexify.jsFile · 0.70
_duplexifyFunction · 0.70

Calls 7

isFinishedFunction · 0.85
isServerRequestFunction · 0.85
isDestroyedFunction · 0.70
isRequestFunction · 0.70
abortMethod · 0.65
closeMethod · 0.65
destroyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…