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

Function onFinish

lib/internal/streams/writable.js:886–904  ·  view source on GitHub ↗
(stream, state, err)

Source from the content-addressed store, hash-verified

884}
885
886function onFinish(stream, state, err) {
887 if ((state[kState] & kPrefinished) !== 0) {
888 errorOrDestroy(stream, err ?? new ERR_MULTIPLE_CALLBACK());
889 return;
890 }
891 state.pendingcb--;
892 if (err) {
893 callFinishedCallbacks(state, err);
894 errorOrDestroy(stream, err, (state[kState] & kSync) !== 0);
895 } else if (needFinish(state)) {
896 state[kState] |= kPrefinished;
897 stream.emit('prefinish');
898 // Backwards compat. Don't check state.sync here.
899 // Some streams assume 'finish' will be emitted
900 // asynchronously relative to _final callback.
901 state.pendingcb++;
902 process.nextTick(finish, stream, state);
903 }
904}
905
906function prefinish(stream, state) {
907 if ((state[kState] & (kPrefinished | kFinalCalled)) !== 0) {

Callers 1

prefinishFunction · 0.70

Calls 4

errorOrDestroyFunction · 0.85
callFinishedCallbacksFunction · 0.85
needFinishFunction · 0.85
emitMethod · 0.45

Tested by

no test coverage detected