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

Function closeSession

lib/internal/http2/core.js:1227–1255  ·  view source on GitHub ↗
(session, code, error)

Source from the content-addressed store, hash-verified

1225}
1226
1227function closeSession(session, code, error) {
1228 debugSessionObj(session, 'start closing/destroying', error);
1229
1230 const state = session[kState];
1231 state.flags |= SESSION_FLAGS_DESTROYED;
1232 state.destroyCode = code;
1233
1234 // Clear timeout and remove timeout listeners.
1235 session.setTimeout(0);
1236 session.removeAllListeners('timeout');
1237
1238 const socket = session[kSocket];
1239 const handle = session[kHandle];
1240
1241 // Destroy any pending and open streams
1242 if (state.pendingStreams.size > 0 || state.streams.size > 0) {
1243 const cancel = new ERR_HTTP2_STREAM_CANCEL(error);
1244 state.pendingStreams.forEach((stream) => stream.destroy(cancel));
1245 state.streams.forEach((stream) => stream.destroy(error));
1246 }
1247
1248 // Destroy the handle if it exists at this point.
1249 if (handle !== undefined) {
1250 handle.ondone = finishSessionClose.bind(null, session, error);
1251 handle.destroy(code, socket.destroyed);
1252 } else {
1253 finishSessionClose(session, error);
1254 }
1255}
1256
1257// Upon creation, the Http2Session takes ownership of the socket. The session
1258// may not be ready to use immediately if the socket is not yet fully connected.

Callers 2

destroyMethod · 0.85
socketOnCloseFunction · 0.85

Calls 7

debugSessionObjFunction · 0.85
finishSessionCloseFunction · 0.85
forEachMethod · 0.65
setTimeoutMethod · 0.45
removeAllListenersMethod · 0.45
destroyMethod · 0.45
bindMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…