Skip to content

Commit 05673bb

Browse files
committed
chore: close session on response when disableSessionCache=true
1 parent 9c4307d commit 05673bb

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

packages/node-http-handler/src/node-http2-handler.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,8 @@ describe(NodeHttp2Handler.name, () => {
361361

362362
// @ts-ignore: access private property
363363
const session: ClientHttp2Session = nodeH2Handler.sessionList[0];
364-
expect(session.closed).toBe(false);
364+
// When disableSessionCache:true, session is closed as soon as request gets response.
365+
expect(session.closed).toBe(true);
365366
setTimeout(() => {
366367
expect(session.closed).toBe(true);
367368
expect(session.destroyed).toBe(false);

packages/node-http-handler/src/node-http2-handler.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ export class NodeHttp2Handler implements HttpHandler {
9797
});
9898
fulfilled = true;
9999
resolve({ response: httpResponse });
100+
if (this.disableSessionCache) {
101+
// Gracefully closes the Http2Session, allowing any existing streams to complete
102+
// on their own and preventing new Http2Stream instances from being created.
103+
session.close();
104+
}
100105
});
101106

102107
const requestTimeout = this.requestTimeout;

0 commit comments

Comments
 (0)