Skip to content

Commit 9042df6

Browse files
committed
fix(sdk): retry the resume-cursor scan when the boot lookup fails transiently
A scan that threw was treated the same as one that found no cursor, so the resume-cursor block skipped its retry and the live subscription could replay from the start. Only a successful lookup (including a genuine no-cursor-yet answer) is shared now; a throw leaves the retry available.
1 parent 4a88e92 commit 9042df6

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

  • packages/trigger-sdk/src/v3

packages/trigger-sdk/src/v3/ai.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5418,12 +5418,17 @@ function chatAgent<
54185418
: undefined;
54195419
if (snapshotInCursor !== undefined && Number.isFinite(snapshotInCursor)) {
54205420
bootInCursor = snapshotInCursor;
5421+
bootInCursorResolved = true;
54215422
} else {
5422-
bootInCursor = await findLatestSessionInCursor(payload.chatId).catch(
5423-
() => undefined
5424-
);
5423+
try {
5424+
bootInCursor = await findLatestSessionInCursor(payload.chatId);
5425+
bootInCursorResolved = true;
5426+
} catch {
5427+
// Transient scan failure: leave unresolved so the
5428+
// resume-cursor block below retries the lookup.
5429+
bootInCursor = undefined;
5430+
}
54255431
}
5426-
bootInCursorResolved = true;
54275432
bootSpan.setAttribute(
54285433
"chat.boot.replay.in.cursorFromSnapshot",
54295434
snapshotInCursor !== undefined

0 commit comments

Comments
 (0)