fix: avoid locally caught ACP session init exception (#55136) (thanks @doguabaris)

This commit is contained in:
Doğu Abaris
2026-04-01 19:46:22 +02:00
committed by GitHub
parent dd7df0753f
commit 5190b3b3fa

View File

@@ -357,19 +357,15 @@ export class AcpSessionManager {
state: "idle",
lastActivityAt: Date.now(),
};
let persisted: SessionEntry | null = null;
try {
const persisted = await this.writeSessionMeta({
persisted = await this.writeSessionMeta({
cfg: input.cfg,
sessionKey,
mutate: () => meta,
failOnError: true,
});
if (!persisted?.acp) {
throw new AcpRuntimeError(
"ACP_SESSION_INIT_FAILED",
`Could not persist ACP metadata for ${sessionKey}.`,
);
}
} catch (error) {
await runtime
.close({
@@ -383,6 +379,24 @@ export class AcpSessionManager {
});
throw error;
}
if (!persisted?.acp) {
await runtime
.close({
handle,
reason: "init-meta-failed",
})
.catch((closeError) => {
logVerbose(
`acp-manager: cleanup close failed after metadata write error for ${sessionKey}: ${String(closeError)}`,
);
});
throw new AcpRuntimeError(
"ACP_SESSION_INIT_FAILED",
`Could not persist ACP metadata for ${sessionKey}.`,
);
}
this.setCachedRuntimeState(sessionKey, {
runtime,
handle,