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

Function finishSessionClose

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

Source from the content-addressed store, hash-verified

1193}
1194
1195function finishSessionClose(session, error) {
1196 debugSessionObj(session, 'finishSessionClose');
1197
1198 const socket = session[kSocket];
1199 cleanupSession(session);
1200
1201 if (socket && !socket.destroyed) {
1202 socket.on('close', () => {
1203 emitClose(session, error);
1204 });
1205 if (session.closed) {
1206 // If we're gracefully closing the socket, call resume() so we can detect
1207 // the peer closing in case binding.Http2Session is already gone.
1208 socket.resume();
1209 }
1210
1211 // Always wait for writable side to finish.
1212 socket.end((err) => {
1213 debugSessionObj(session, 'finishSessionClose socket end', err, error);
1214 // If session.destroy() was called, destroy the underlying socket. Delay
1215 // it a bit to try to avoid ECONNRESET on Windows.
1216 if (!session.closed) {
1217 setImmediate(() => {
1218 socket.destroy(error);
1219 });
1220 }
1221 });
1222 } else {
1223 process.nextTick(emitClose, session, error);
1224 }
1225}
1226
1227function closeSession(session, code, error) {
1228 debugSessionObj(session, 'start closing/destroying', error);

Callers 1

closeSessionFunction · 0.85

Calls 8

debugSessionObjFunction · 0.85
cleanupSessionFunction · 0.85
emitCloseFunction · 0.85
resumeMethod · 0.65
setImmediateFunction · 0.50
onMethod · 0.45
endMethod · 0.45
destroyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…