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

Function onConstruct

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

Source from the content-addressed store, hash-verified

270 let called = false;
271
272 function onConstruct(err) {
273 if (called) {
274 errorOrDestroy(stream, err ?? new ERR_MULTIPLE_CALLBACK());
275 return;
276 }
277 called = true;
278
279 const r = stream._readableState;
280 const w = stream._writableState;
281 const s = w || r;
282
283 if (r) {
284 r[kState] |= kConstructed;
285 }
286 if (w) {
287 w[kState] |= kConstructed;
288 }
289
290 if (s.destroyed) {
291 stream.emit(kDestroy, err);
292 } else if (err) {
293 errorOrDestroy(stream, err, true);
294 } else {
295 stream.emit(kConstruct);
296 }
297 }
298
299 try {
300 stream._construct((err) => {

Callers

nothing calls this directly

Calls 2

errorOrDestroyFunction · 0.85
emitMethod · 0.45

Tested by

no test coverage detected