Say only what canCarry() and droppedWhileDraining() can know
Test / lint (pull_request) Successful in 23s
Test / test (18) (pull_request) Successful in 32s
Test / test (20) (pull_request) Successful in 31s
Test / test (22) (pull_request) Successful in 31s
Test / test (24) (pull_request) Successful in 31s
Test / test (26) (pull_request) Successful in 31s
Mirror / push (push) Has been cancelled

This commit was merged in pull request #38.
This commit is contained in:
2026-09-28 01:34:55 +02:00
parent 8d443bf670
commit bfd0ed1b98
+2 -3
View File
@@ -51,12 +51,11 @@ export class OutgoingRequests {
this.window = new SendWindow({ limit: options.maxOutstanding, log: options.log }); this.window = new SendWindow({ limit: options.maxOutstanding, log: options.log });
} }
/** Whether a request made now reaches the socket. Read through a method: a drop can land while one awaits. */
canCarry(): boolean { canCarry(): boolean {
return this.gate.isUp() && !this.transport.sock.destroyed; return this.gate.isUp() && !this.transport.sock.destroyed;
} }
/** The link went while draining, so the teardown settled what the drain waited on, not the peer. */ /** The link went before the drain finished, so an empty window says nothing about the peer. */
droppedWhileDraining(): boolean { droppedWhileDraining(): boolean {
return this.draining && !this.canCarry(); return this.draining && !this.canCarry();
} }
@@ -89,7 +88,7 @@ export class OutgoingRequests {
if (wrong) return Promise.resolve({ err: wrong }); if (wrong) return Promise.resolve({ err: wrong });
// With no link, the gate answers instead, and says closed. // With no link, the request is refused as closed further on.
if (this.draining && this.canCarry()) { if (this.draining && this.canCarry()) {
return Promise.resolve({ err: new Error('Session is shutting down') }); return Promise.resolve({ err: new Error('Session is shutting down') });
} }