Skip to content

Commit a382a02

Browse files
committed
fix(init): add Sentry observability to stale-step recovery path
Previously the recovery path had no observability — there was no way to tell from Sentry whether the fix was working in production. - addBreadcrumb when recovery succeeds: appears in subsequent traces so we can confirm the recovery mechanism is actually being triggered and seamlessly continuing the wizard. - captureException (warning) when recovery fails: creates a separate trackable event tagged wizard.stale_step_recovery=failed with the step ID and run ID so we can investigate edge cases where runById is unreachable or returns unexpected data. The server-side CLI-SERVER-9 events (from withWorkflowErrorCapture) continue to fire on each "step not suspended" 500, but these new client-side events tell us the outcome of the recovery attempt.
1 parent 15c21c1 commit a382a02

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

src/lib/init/wizard-runner.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { randomBytes } from "node:crypto";
1515

1616
import { MastraClient } from "@mastra/client-js";
1717
import {
18+
addBreadcrumb,
1819
captureException,
1920
getTraceData,
2021
setTag,
@@ -509,10 +510,24 @@ async function resumeWithRetry(
509510
spin.message("Reconnecting...");
510511
const recovered = await tryRecoverCurrentRunState(workflow, run.runId);
511512
if (recovered) {
513+
addBreadcrumb({
514+
category: "wizard",
515+
message: `stale-step recovery succeeded for ${stepId}`,
516+
level: "info",
517+
data: { stepId, runId: run.runId },
518+
});
512519
return recovered;
513520
}
514521
// Recovery failed — the step is confirmed not suspended and retrying
515522
// it will always 500. Throw immediately instead of wasting 14s.
523+
captureException(err, {
524+
level: "warning",
525+
tags: {
526+
"wizard.stale_step_recovery": "failed",
527+
"wizard.resume_step": stepId,
528+
},
529+
extra: { runId: run.runId },
530+
});
516531
throw err;
517532
}
518533
if (attempt === MAX_RESUME_RETRIES) {

0 commit comments

Comments
 (0)