Skip to content

Commit 0a2af5c

Browse files
committed
wip: small clean up
* Related #4 [ci skip]
1 parent 9c901ff commit 0a2af5c

File tree

2 files changed

+5
-24
lines changed

2 files changed

+5
-24
lines changed

src/QUICConnection.ts

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,6 @@ class QUICConnection extends EventTarget {
347347
}
348348
// Sending if
349349
await this.send();
350-
this.logger.debug(
351-
`state are draining: ${this.conn.isDraining()}, closed: ${this.conn.isClosed()}`,
352-
);
353350
// If it is not closed, it could still be draining
354351
this.logger.debug('Waiting for closeP');
355352
await this.closedP;
@@ -494,18 +491,11 @@ class QUICConnection extends EventTarget {
494491
}
495492
} finally {
496493
this.logger.debug('RECV FINALLY');
497-
this.logger.debug(
498-
` ________ ED: ${this.conn.isInEarlyData()} TO: ${this.conn.isTimedOut()} EST: ${this.conn.isEstablished()}`,
499-
);
500-
501494
// Set the timeout
502495
this.checkTimeout();
503496
// If this call wasn't executed in the midst of a destroy
504497
// and yet the connection is closed or is draining, then
505498
// we need to destroy this connection
506-
this.logger.debug(
507-
`state are draining: ${this.conn.isDraining()}, closed: ${this.conn.isClosed()}`,
508-
);
509499
if (
510500
this[status] !== 'destroying' &&
511501
(this.conn.isClosed() || this.conn.isDraining())
@@ -699,9 +689,6 @@ class QUICConnection extends EventTarget {
699689
this.deadline = Infinity;
700690
// Doing timeout actions
701691
this.conn.onTimeout();
702-
this.logger.debug(
703-
`state are draining: ${this.conn.isDraining()}, closed: ${this.conn.isClosed()}`,
704-
);
705692
if (this[destroyed] === false) await this.send();
706693
if (
707694
this[status] !== 'destroying' &&
@@ -728,36 +715,34 @@ class QUICConnection extends EventTarget {
728715
this.logger.debug('timeout checking timeout');
729716
// During construction, this ends up being null
730717
const time = this.conn.timeout();
731-
this.logger.debug(`timeout time ${time}`);
732718
if (time == null) {
733719
// Clear timeout
734-
this.logger.debug('timeout clearing timeout');
720+
if (this.timer != null) this.logger.debug('timeout clearing timeout');
735721
clearTimeout(this.timer);
736722
delete this.timer;
737723
this.deadline = Infinity;
738724
} else {
739725
const newDeadline = Date.now() + time;
740726
if (this.timer != null) {
741-
this.logger.debug('timeout already running');
742727
if (time === 0) {
743-
this.logger.debug('timeout instant timeout');
728+
this.logger.debug('timeout triggering instant timeout');
744729
// Skip timer and call onTimeout
745730
setImmediate(this.onTimeout);
746731
} else if (newDeadline < this.deadline) {
747-
this.logger.debug(`timeout updating timer`);
732+
this.logger.debug(`timeout updating timer with ${time} delay`);
748733
clearTimeout(this.timer);
749734
delete this.timer;
750735
this.deadline = newDeadline;
751736
this.timer = setTimeout(this.onTimeout, time);
752737
}
753738
} else {
754739
if (time === 0) {
755-
this.logger.debug('timeout instant timeout');
740+
this.logger.debug('timeout triggering instant timeout');
756741
// Skip timer and call onTimeout
757742
setImmediate(this.onTimeout);
758743
return;
759744
}
760-
this.logger.debug('timeout creating timer');
745+
this.logger.debug(`timeout creating timer with ${time} delay`);
761746
this.deadline = newDeadline;
762747
this.timer = setTimeout(this.onTimeout, time);
763748
}

tests/QUICClient.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import type { Crypto, Host, Port } from '@/types';
22
import type * as events from '@/events';
3-
import dgram from 'dgram';
43
import Logger, { LogLevel, StreamHandler, formatting } from '@matrixai/logger';
54
import { fc, testProp } from '@fast-check/jest';
65
import QUICClient from '@/QUICClient';
76
import QUICServer from '@/QUICServer';
87
import * as errors from '@/errors';
98
import { promise } from '@/utils';
10-
import QUICSocket from '@/QUICSocket';
119
import * as testsUtils from './utils';
1210
import { tlsConfigWithCaArb } from './tlsUtils';
1311
import { sleep } from './utils';
@@ -598,8 +596,6 @@ describe(QUICClient.name, () => {
598596
await server.start({
599597
host: '127.0.0.1' as Host,
600598
});
601-
// @ts-ignore: kidnap protected property
602-
const socket = server.socket;
603599
// The server can send packets
604600
// Should send 4 packets in 2 seconds
605601
const clientProm = sleep(1000)

0 commit comments

Comments
 (0)