fix(query): recover expired manual transaction sessions

This commit is contained in:
t8y2 committed 2026-08-24 12:19:27 +08:00
1 parent 0047d79974
commit e03cc2d269
15 files changed
+252 -24

No files matched your search

@@ -22,6 +22,8 @@ export interface BackendError {
helpUrl?: string;
}
export const MANUAL_TRANSACTION_SESSION_EXPIRED_CODE = "DBX-TXN-1001";
const MAX_FALLBACK_CHARS = 64 * 1024;
const MAX_ERROR_PARSE_DEPTH = 16;
const AGENT_RPC_ERROR_DATA_MARKER = "\nDBX_AGENT_ERROR_DATA:";
@@ -84,6 +86,12 @@ export function normalizeBackendError(error: unknown): BackendError | null {
return normalizeBackendErrorAtDepth(error, new WeakSet<object>(), 0);
}
export function isManualTransactionSessionExpired(error: unknown): boolean {
if (normalizeBackendError(error)?.code === MANUAL_TRANSACTION_SESSION_EXPIRED_CODE) return true;
const message = error instanceof Error ? error.message : typeof error === "string" ? error : undefined;
return message?.startsWith("Transaction session not found or expired;") === true || message === "Transaction was auto-rolled back due to 5 minutes of inactivity";
}
function normalizeBackendErrorAtDepth(error: unknown, seen: WeakSet<object>, depth: number): BackendError | null {
if (depth > MAX_ERROR_PARSE_DEPTH) return null;