Skip to content

Commit 241403b

Browse files
committed
chore: rename disableSessionCache to disableConcurrentStreams
1 parent b58c89e commit 241403b

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -290,25 +290,25 @@ describe(NodeHttp2Handler.name, () => {
290290
const requestTimeout = 200;
291291

292292
describe("does not throw error when request not timed out", () => {
293-
it("disableSessionCache: false (default)", async () => {
293+
it("disableConcurrentStreams: false (default)", async () => {
294294
mockH2Server.removeAllListeners("request");
295295
mockH2Server.on("request", createResponseFunctionWithDelay(mockResponse, requestTimeout - 100));
296296

297297
nodeH2Handler = new NodeHttp2Handler({ requestTimeout });
298298
await nodeH2Handler.handle(new HttpRequest(getMockReqOptions()), {});
299299
});
300300

301-
it("disableSessionCache: true", async () => {
301+
it("disableConcurrentStreams: true", async () => {
302302
mockH2Server.removeAllListeners("request");
303303
mockH2Server.on("request", createResponseFunctionWithDelay(mockResponse, requestTimeout - 100));
304304

305-
nodeH2Handler = new NodeHttp2Handler({ requestTimeout, disableSessionCache: true });
305+
nodeH2Handler = new NodeHttp2Handler({ requestTimeout, disableConcurrentStreams: true });
306306
await nodeH2Handler.handle(new HttpRequest(getMockReqOptions()), {});
307307
});
308308
});
309309

310310
describe("throws timeoutError on requestTimeout", () => {
311-
it("disableSessionCache: false (default)", async () => {
311+
it("disableConcurrentStreams: false (default)", async () => {
312312
mockH2Server.removeAllListeners("request");
313313
mockH2Server.on("request", createResponseFunctionWithDelay(mockResponse, requestTimeout + 100));
314314

@@ -319,11 +319,11 @@ describe(NodeHttp2Handler.name, () => {
319319
});
320320
});
321321

322-
it("disableSessionCache: true", async () => {
322+
it("disableConcurrentStreams: true", async () => {
323323
mockH2Server.removeAllListeners("request");
324324
mockH2Server.on("request", createResponseFunctionWithDelay(mockResponse, requestTimeout + 100));
325325

326-
nodeH2Handler = new NodeHttp2Handler({ requestTimeout, disableSessionCache: true });
326+
nodeH2Handler = new NodeHttp2Handler({ requestTimeout, disableConcurrentStreams: true });
327327
await rejects(nodeH2Handler.handle(new HttpRequest(getMockReqOptions()), {}), {
328328
name: "TimeoutError",
329329
message: `Stream timed out because of no activity for ${requestTimeout} ms`,
@@ -336,7 +336,7 @@ describe(NodeHttp2Handler.name, () => {
336336
const sessionTimeout = 200;
337337

338338
describe("destroys session on sessionTimeout", () => {
339-
it("disableSessionCache: false (default)", async (done) => {
339+
it("disableConcurrentStreams: false (default)", async (done) => {
340340
nodeH2Handler = new NodeHttp2Handler({ sessionTimeout });
341341
await nodeH2Handler.handle(new HttpRequest(getMockReqOptions()), {});
342342

@@ -354,8 +354,8 @@ describe(NodeHttp2Handler.name, () => {
354354
}, sessionTimeout + 100);
355355
});
356356

357-
it("disableSessionCache: true", async (done) => {
358-
nodeH2Handler = new NodeHttp2Handler({ sessionTimeout, disableSessionCache: true });
357+
it("disableConcurrentStreams: true", async (done) => {
358+
nodeH2Handler = new NodeHttp2Handler({ sessionTimeout, disableConcurrentStreams: true });
359359
await nodeH2Handler.handle(new HttpRequest(getMockReqOptions()), {});
360360

361361
// @ts-ignore: access private property
@@ -369,10 +369,10 @@ describe(NodeHttp2Handler.name, () => {
369369
});
370370
});
371371

372-
describe("disableSessionCache", () => {
372+
describe("disableConcurrentStreams", () => {
373373
beforeEach(() => {
374374
nodeH2Handler = new NodeHttp2Handler({
375-
disableSessionCache: true,
375+
disableConcurrentStreams: true,
376376
});
377377
});
378378

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,27 @@ export interface NodeHttp2HandlerOptions {
2424
sessionTimeout?: number;
2525

2626
/**
27-
* Disables sharing ClientHttp2Session instance between different HTTP/2 requests
28-
* sent to the same URL. When set to true, it will create a new session instance for
29-
* each request to a URL. **Default:** false.
27+
* Disables processing concurrent streams on a ClientHttp2Session instance. When set
28+
* to true, the handler will create a new session instance for each request to a URL.
29+
* **Default:** false.
3030
* https://nodejs.org/api/http2.html#http2_class_clienthttp2session
3131
*/
32-
disableSessionCache?: boolean;
32+
disableConcurrentStreams?: boolean;
3333
}
3434

3535
export class NodeHttp2Handler implements HttpHandler {
3636
private readonly requestTimeout?: number;
3737
private readonly sessionTimeout?: number;
38-
private readonly disableSessionCache?: boolean;
38+
private readonly disableConcurrentStreams?: boolean;
3939

4040
public readonly metadata = { handlerProtocol: "h2" };
4141
private sessionList: ClientHttp2Session[];
4242
private sessionCache: Map<string, ClientHttp2Session>;
4343

44-
constructor({ requestTimeout, sessionTimeout, disableSessionCache }: NodeHttp2HandlerOptions = {}) {
44+
constructor({ requestTimeout, sessionTimeout, disableConcurrentStreams }: NodeHttp2HandlerOptions = {}) {
4545
this.requestTimeout = requestTimeout;
4646
this.sessionTimeout = sessionTimeout;
47-
this.disableSessionCache = disableSessionCache;
47+
this.disableConcurrentStreams = disableConcurrentStreams;
4848
this.sessionList = [];
4949
this.sessionCache = new Map<string, ClientHttp2Session>();
5050
}
@@ -71,10 +71,10 @@ export class NodeHttp2Handler implements HttpHandler {
7171

7272
const { hostname, method, port, protocol, path, query } = request;
7373
const authority = `${protocol}//${hostname}${port ? `:${port}` : ""}`;
74-
const session = this.disableSessionCache ? this.getSession(authority) : this.getSessionFromCache(authority);
74+
const session = this.disableConcurrentStreams ? this.getSession(authority) : this.getSessionFromCache(authority);
7575

7676
const reject = (err: Error) => {
77-
if (this.disableSessionCache) {
77+
if (this.disableConcurrentStreams) {
7878
this.destroySession(session);
7979
}
8080
fulfilled = true;
@@ -97,7 +97,7 @@ export class NodeHttp2Handler implements HttpHandler {
9797
});
9898
fulfilled = true;
9999
resolve({ response: httpResponse });
100-
if (this.disableSessionCache) {
100+
if (this.disableConcurrentStreams) {
101101
// Gracefully closes the Http2Session, allowing any existing streams to complete
102102
// on their own and preventing new Http2Stream instances from being created.
103103
session.close();

0 commit comments

Comments
 (0)