Split linkDown() into canCarry() and droppedWhileDraining()
Test / lint (pull_request) Successful in 23s
Test / test (18) (pull_request) Successful in 31s
Test / test (20) (pull_request) Successful in 31s
Test / test (22) (pull_request) Successful in 34s
Test / test (24) (pull_request) Successful in 40s
Test / test (26) (pull_request) Successful in 33s
Mirror / push (push) Waiting to run

This commit is contained in:
2026-09-28 01:31:39 +02:00
parent 1371137fef
commit 8d443bf670
4 changed files with 16 additions and 16 deletions
+3 -3
View File
@@ -333,7 +333,8 @@ export class Session extends EventEmitter<SessionEvents> {
this.reconnectLoop?.stop();
this.outgoing.stopAccepting();
if (this.outgoing.linkDown()) return {};
// No link, so nothing is on the wire to wait out.
if (!this.outgoing.canCarry()) return {};
const timeout = this.options.shutdownTimeout ?? defaults.shutdownTimeout;
const deadline = timeout > 0 ? Date.now() + timeout : 0;
@@ -341,8 +342,7 @@ export class Session extends EventEmitter<SessionEvents> {
const messages = await this.incoming.drain(this.answering(timeout), signal);
const requests = await this.outgoing.drain(leftOf(deadline), signal);
// The window empties on a teardown too, which settles everything the link was carrying.
if (this.outgoing.linkDown()) {
if (this.outgoing.droppedWhileDraining()) {
return { err: new Error('The session closed before the drain finished') };
}