Skip to content

Commit f0455ca

Browse files
committed
fix: updating config defaults
[ci skip]
1 parent dc30d95 commit f0455ca

File tree

4 files changed

+31
-12
lines changed

4 files changed

+31
-12
lines changed

src/QUICClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { quiche } from './native';
1616
import * as utils from './utils';
1717
import * as errors from './errors';
1818
import * as events from './events';
19-
import { clientDefault } from './config';
19+
import { clientDefault, minIdleTimeout } from './config';
2020
import QUICSocket from './QUICSocket';
2121
import QUICConnection from './QUICConnection';
2222
import QUICConnectionId from './QUICConnectionId';
@@ -87,7 +87,7 @@ class QUICClient extends EventTarget {
8787
},
8888
ctx?: Partial<ContextTimedInput>,
8989
): PromiseCancellable<QUICClient>;
90-
@timedCancellable(true, Infinity, errors.ErrorQUICClientCreateTimeOut)
90+
@timedCancellable(true, minIdleTimeout, errors.ErrorQUICClientCreateTimeOut)
9191
public static async createQUICClient(
9292
{
9393
host,

src/QUICConnection.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { Timer } from '@matrixai/timer';
2626
import { context, timedCancellable } from '@matrixai/contexts/dist/decorators';
2727
import { withF } from '@matrixai/resources';
2828
import { utils as contextsUtils } from '@matrixai/contexts';
29-
import { buildQuicheConfig } from './config';
29+
import { buildQuicheConfig, minIdleTimeout } from './config';
3030
import QUICStream from './QUICStream';
3131
import { quiche } from './native';
3232
import * as events from './events';
@@ -237,7 +237,11 @@ class QUICConnection extends EventTarget {
237237
},
238238
ctx?: Partial<ContextTimedInput>,
239239
): PromiseCancellable<QUICConnection>;
240-
@timedCancellable(true, Infinity, errors.ErrorQUICConnectionStartTimeOut)
240+
@timedCancellable(
241+
true,
242+
minIdleTimeout,
243+
errors.ErrorQUICConnectionStartTimeOut,
244+
)
241245
public static async createQUICConnection(
242246
args:
243247
| {

src/QUICServer.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class QUICServer extends EventTarget {
5353
protected codeToReason: StreamCodeToReason | undefined;
5454
protected verifyCallback: VerifyCallback | undefined;
5555
protected connectionMap: QUICConnectionMap;
56-
protected connectTimeoutTime: number;
56+
protected minIdleTimeout: number | undefined;
5757
// Used to track address string for logging ONLY
5858
protected address: string;
5959

@@ -110,7 +110,7 @@ class QUICServer extends EventTarget {
110110
reasonToCode,
111111
codeToReason,
112112
verifyCallback,
113-
connectTimeoutTime = 15000,
113+
minIdleTimeout,
114114
logger,
115115
}: {
116116
crypto: {
@@ -126,7 +126,7 @@ class QUICServer extends EventTarget {
126126
reasonToCode?: StreamReasonToCode;
127127
codeToReason?: StreamCodeToReason;
128128
verifyCallback?: VerifyCallback;
129-
connectTimeoutTime?: number;
129+
minIdleTimeout?: number;
130130
logger?: Logger;
131131
}) {
132132
super();
@@ -154,7 +154,7 @@ class QUICServer extends EventTarget {
154154
this.reasonToCode = reasonToCode;
155155
this.codeToReason = codeToReason;
156156
this.verifyCallback = verifyCallback;
157-
this.connectTimeoutTime = connectTimeoutTime;
157+
this.minIdleTimeout = minIdleTimeout;
158158
}
159159

160160
@ready(new errors.ErrorQUICServerNotRunning())
@@ -379,7 +379,7 @@ class QUICServer extends EventTarget {
379379
.slice(32)}-${clientConnRef}`,
380380
),
381381
},
382-
{ timer: this.connectTimeoutTime },
382+
{ timer: this.minIdleTimeout },
383383
);
384384
} catch (e) {
385385
// Ignoring any errors here as a failure to connect

src/config.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,26 @@ const sigalgs = [
2323
'ed25519',
2424
].join(':');
2525

26+
/**
27+
* Usually we would create separate timeouts for connecting vs idling.
28+
* Unfortunately quiche only has 1 config option that controls both.
29+
* And it is not possible to mutate this option after connecting.
30+
* Therefore, this option is just a way to set a shorter connecting timeout
31+
* compared to the idling timeout.
32+
* If this is the larger than the `maxIdleTimeout` (remember that `0` is `Infinity`) for `maxIdleTimeout`, then this has no effect.
33+
* This only has an effect if this is set to a number less than `maxIdleTimeout`.
34+
* Thus, it is the "minimum boundary" of the timeout during connecting.
35+
* While the `maxIdleTimeout` is still the "maximum boundary" during connecting.
36+
*/
37+
const minIdleTimeout = Infinity;
38+
2639
const clientDefault: QUICConfig = {
2740
sigalgs,
2841
verifyPeer: true,
2942
verifyAllowFail: false,
3043
grease: true,
31-
maxIdleTimeout: 1 * 60 * 1000,
44+
keepAliveIntervalTime: undefined,
45+
maxIdleTimeout: 0,
3246
maxRecvUdpPayloadSize: quiche.MAX_DATAGRAM_SIZE, // 65527
3347
maxSendUdpPayloadSize: quiche.MIN_CLIENT_INITIAL_LEN, // 1200,
3448
initialMaxData: 10 * 1024 * 1024,
@@ -48,7 +62,8 @@ const serverDefault: QUICConfig = {
4862
verifyPeer: false,
4963
verifyAllowFail: false,
5064
grease: true,
51-
maxIdleTimeout: 1 * 60 * 1000,
65+
keepAliveIntervalTime: undefined,
66+
maxIdleTimeout: 0,
5267
maxRecvUdpPayloadSize: quiche.MAX_DATAGRAM_SIZE, // 65527
5368
maxSendUdpPayloadSize: quiche.MIN_CLIENT_INITIAL_LEN, // 1200
5469
initialMaxData: 10 * 1024 * 1024,
@@ -188,4 +203,4 @@ function buildQuicheConfig(config: QUICConfig): QuicheConfig {
188203
return quicheConfig;
189204
}
190205

191-
export { clientDefault, serverDefault, buildQuicheConfig };
206+
export { minIdleTimeout, clientDefault, serverDefault, buildQuicheConfig };

0 commit comments

Comments
 (0)