Stop accepting before the drain and report the link that dropped during it

This commit is contained in:
2026-08-30 20:27:38 +02:00
parent bebd74b42b
commit 5c618e0061
10 changed files with 184 additions and 56 deletions
+3 -3
View File
@@ -196,18 +196,18 @@ export async function client(options: ClientOptions = {}): Promise<Result<{ sess
const signal = options.signal;
if (signal?.aborted === true) {
void session.close();
void session.close({ signal });
return { err: new Error('Aborted before binding') };
}
// Registered before the bind: an abort landing while it is in flight has to close the session.
signal?.addEventListener('abort', () => { void session.close(); }, { once: true });
signal?.addEventListener('abort', () => { void session.close({ signal }); }, { once: true });
const bound = await bind(session, options);
if (bound.err) {
void session.close();
void session.close({ signal });
return { err: bound.err };
}