fix: check cancellation status before tearing down terminal session store and connection registry

Moves deleteBySetupSessionId and closeBySetupSessionId to fire only
after the non-terminal status guard, so terminal resources are not torn
down when a forced delete is rejected due to a failed custom-image
session cancellation.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Harold KimandPaperclip committed 2026-07-09 09:59:45 +00:00
1 parent 7bd74c3784
commit c5c08b0089
1 file changed
+5 -5
+5 -5
View File
@@ -335,17 +335,17 @@ export function environmentRoutes(
sessionId: overview.activeSession.id,
reason: "environment_deleted",
});
environmentCustomImageTerminalSessionStore.deleteBySetupSessionId(overview.activeSession.id);
environmentCustomImageTerminalConnectionRegistry.closeBySetupSessionId(
overview.activeSession.id,
"environment_deleted",
);
if (cancelled.status === "failed" || ACTIVE_CUSTOM_IMAGE_SETUP_STATUSES_FOR_DELETE.has(cancelled.status)) {
throw conflict(
"Environment delete could not cancel the active custom image setup session. Retry after the failed setup cleanup is resolved.",
{ setupSessionId: cancelled.id },
);
}
environmentCustomImageTerminalSessionStore.deleteBySetupSessionId(overview.activeSession.id);
environmentCustomImageTerminalConnectionRegistry.closeBySetupSessionId(
overview.activeSession.id,
"environment_deleted",
);
}
}
}