1886
return this._shutdownPromise ??= (async () => {
1887
for (const entry of this._sessions.values()) {
1888
>
// Provisional chats (a default or peer whose first send's
claudeAgent.ts
1889
>
// materialize is in-flight) race on their own abort controller —
1890
>
// abort them up front so a queued `sdk.startup()` unwinds
1891
>
// promptly rather than running past shutdown until its teardown
1892
>
// task dequeues.
1893
>
for (const chat of entry.allChatSessions()) {
1894
>
if (!chat.isPipelineReady) {
1895
>
chat.abortController.abort();
1896
>
}
1897
>
}
1898
>
}
1899
1900
const sessionIds = [...this._sessions.keys()];
1901
await Promise.all(sessionIds.map(sessionId =>
1902
>
this._disposeSequencer.queue(sessionId, async () => {
claudeAgent.ts
1903
>
await this._teardownEntry(sessionId);
1904
>
this._pruneActiveClientHandles(sessionId);
1905
>
})
1906
));
1907
})();