(session, code, error)
| 1225 | } |
| 1226 | |
| 1227 | function 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. |
no test coverage detected
searching dependent graphs…