Skip to content

Commit fd4d6b9

Browse files
quic: remove redundant === 0n checks in kFinishClose method
remove unreachable conditional checks in kFinishClose (lib/internal/quic/quic.js:13861401) that were redundant due to an early return, reducing code complexity.
1 parent 3ac88a7 commit fd4d6b9

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

lib/internal/quic/quic.js

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ const onSessionHandshakeChannel = dc.channel('quic.session.handshake');
352352
* @property {bigint|number} [maxConnectionsTotal] The maximum number of total connections
353353
* @property {bigint|number} [maxStatelessResetsPerHost] The maximum number of stateless resets per host
354354
* @property {bigint|number} [addressLRUSize] The size of the address LRU cache
355-
* @property {bigint|number} [maxRetries] The maximum number of retriesw
355+
* @property {bigint|number} [maxRetries] The maximum number of retries
356356
* @property {number} [rxDiagnosticLoss] The receive diagnostic loss probability (range 0.0-1.0)
357357
* @property {number} [txDiagnosticLoss] The transmit diagnostic loss probability (range 0.0-1.0)
358358
* @property {number} [udpReceiveBufferSize] The UDP receive buffer size
@@ -507,7 +507,7 @@ setCallbacks({
507507
if (session.destroyed) {
508508
stream.destroy();
509509
return;
510-
};
510+
}
511511
session[kNewStream](stream, direction);
512512
},
513513

@@ -1383,29 +1383,21 @@ class QuicSession {
13831383
debug('finishing closing the session with an error', errorType, code, reason);
13841384
// Otherwise, errorType indicates the type of error that occurred, code indicates
13851385
// the specific error, and reason is an optional string describing the error.
1386+
// Note: code is guaranteed to be non-zero here due to early return above
13861387
switch (errorType) {
13871388
case 0: /* Transport Error */
1388-
if (code === 0n) {
1389-
this.destroy();
1390-
} else {
1391-
this.destroy(new ERR_QUIC_TRANSPORT_ERROR(code, reason));
1392-
}
1389+
this.destroy(new ERR_QUIC_TRANSPORT_ERROR(code, reason));
13931390
break;
13941391
case 1: /* Application Error */
1395-
if (code === 0n) {
1396-
this.destroy();
1397-
} else {
1398-
this.destroy(new ERR_QUIC_APPLICATION_ERROR(code, reason));
1399-
}
1392+
this.destroy(new ERR_QUIC_APPLICATION_ERROR(code, reason));
14001393
break;
14011394
case 2: /* Version Negotiation Error */
14021395
this.destroy(new ERR_QUIC_VERSION_NEGOTIATION_ERROR());
14031396
break;
1404-
case 3: /* Idle close */ {
1397+
case 3: /* Idle close */
14051398
// An idle close is not really an error. We can just destroy.
14061399
this.destroy();
14071400
break;
1408-
}
14091401
}
14101402
}
14111403

0 commit comments

Comments
 (0)