fix(server): a failed scheduled run shows its error without a stack trace #29889
main fromrefs/pull/29889/head·merged by maria-rcks View on GitHubProblem#
When a scheduled task run fails to start, lastRunError holds Cause.pretty(cause). That is the error name plus a multi-line stack trace with server file paths. Triggers include a webhook delivery, a timed run, or Run now, whenever the thread launch or the send to a bound thread fails (for example, the bound thread was deleted). Settings on web ("Scheduled tasks" row) and mobile ("Last run failed: …") show this text, and the MCP list_scheduled_tasks result returns it to agents. So the user sees ThreadManagementThreadNotFoundError: … at file:///…/ScheduledTaskService.ts:… where a plain message would do.
Change#
errorMessage in ScheduledTaskService.ts now squashes the cause to its main error and keeps only the message. This matches the existing errorMessage(Cause.squash(cause)) pattern in apps/server/src/mcp/WorktreeMcpService.ts. Both callers benefit: the run-completion record and releaseStuckRun. Webhook delivery-log entries already use fixed messages, so they do not change.
Scope and approval#
This is a very small, focused fix for an obvious bug, so there is no prior issue. Users should never see an internal stack trace in a status line. The fix changes 3 lines of one helper and adds one assertion to an existing test.
Overlap search: the local PR index and GitHub search for lastRunError, "stack trace" and scheduled-task error PRs. #23131 (scheduled runs record how their turn ended) and #19774 (report scheduled worktree preparation failures) are open and touch the same file. Neither changes errorMessage or how a cause is turned into the message. #19097 fixed the same class of problem for the provider session banner and was closed without merging.
Verification#
- Red on main: I extended
start failures release both replay keys and relay claims for redeliveryinScheduledTaskService.webhook.test.tsto assertlastRunErrorafter the injected start failure. It failed withAssertionError: expected 'Error: injected start failure\n at…' to equal 'injected start failure'. - Green:
vp test run src/scheduledTaskspassed 9 files and 104 tests. vp run check:changedpassed format, lint, knip, graphql, typecheck (3 packages) and tests (5 files, 79 tests).- Probe of
Cause.squash: a typed failure gives its message ("Thread not found."), a defect gives the Error message, and an interrupt-only cause gives "All fibers interrupted without error". The failure types that launch and send declare are Error subclasses. - Not checked: a real client capture. The text change has no layout effect.
Reviewed with sol-loop: 1 round with GPT-6.1 Sol on high. Sol verdict: approved.
Created with Claude Opus 5.5 in Claude Code (T3 Code).
🤖 Generated with Claude Code
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
No actionable comments were generated in the recent review.
Walkthrough
-
The scheduled-task error formatter now uses the message from a squashed Effect
Causewhen it is anError, and otherwise stringifies the result. A webhook test checks the recorded error after a failed start.Changes: Scheduled task error reporting
Layer / File(s) Summary Format recorded task errors
apps/server/src/scheduledTasks/ScheduledTaskService.ts,apps/server/src/scheduledTasks/ScheduledTaskService.webhook.test.tsThe formatter uses the squashed Cause's Error.messagewhen available and otherwise stringifies the result. The webhook test checks thatlastRunErroris"injected start failure"after a failed start.Estimated code review effort: 2 (Simple) | ~8 minutes
Change: Bug fix
Possibly related PRs
- pingdotgg/t3code#24561: Changes scheduled-run completion and failure recording in
ScheduledTaskService, which uses the error formatter changed here. - pingdotgg/t3code#28474: Changes interrupted-run cleanup and
releaseStuckRuninScheduledTaskService, which records errors using the formatter changed here. - pingdotgg/t3code#21793: Makes run completion and stuck-run release transactional in the same scheduled-run transition paths.
Suggested reviewers:
juliusmarminge,macroscopeapp - pingdotgg/t3code#24561: Changes scheduled-run completion and failure recording in
Merge Risk:
Minimal · up to0d6d3-
The change prevents scheduled-task status errors from exposing stack details while preserving useful failure messages, with no merge-blocking risk identified.
Pre-merge checks:
4-
Check name Status Explanation Title check The title clearly and concisely describes the main change: scheduled-run errors no longer expose stack traces. Description check The description includes complete Problem, Change, Scope and approval, and Verification sections. It explains the bug, the implementation, the focused scope, test results, and the unverified client ca… Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request. Full details: Description check
-
Explanation
The description includes complete Problem, Change, Scope and approval, and Verification sections. It explains the bug, the implementation, the focused scope, test results, and the unverified client capture.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Warning
Some tools did not complete. Review the errors below.
ast-grep (0.51.1)-
ast-grep could not parse rule config: /ast-grep-rules/ast-grep-essentials/rules/scala/security/jwt-scala-hardcode-scala.yml
Usage-based review receipt#
- Mode: Continue automatically
- Reviewed files: 2
- Charged: $0.50
- View usage details
Note
This review was completed with usage-based billing: files reviewed beyond your plan's included limits are billed at $0.25/file. View usage-based billing.
CodeRabbit Verify#
- Run CodeRabbit Verify to test the changes in this pull request.
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: main
- File: .coderabbit.config.ts
- Commit: 61c3794
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Advanced
- Run ID:
5628282f-e94a-498d-a452-2f6fc6a18077
Commits-
Reviewing files that changed from the base of the PR and between 61c3794c32b0eeebfac09add43e403618c65d2d7 and 0d6d391fd9174f358382a03fead4a65556693a00.
Files selected for processing: 2-
apps/server/src/scheduledTasks/ScheduledTaskService.tsapps/server/src/scheduledTasks/ScheduledTaskService.webhook.test.ts
Limit details: You’ve used all 10 included reviews currently available.
-
-
Note
Written by
gpt-6.1-solon behalf of MariaVerified in a real dev environment#
verified as-is at
0d6d391fd9174f358382a03fead4a65556693a00on a linux boat vm. no source changes or pushes were needed.used separate main and pr checkouts,
vp i, and one backgroundvp run devserver at a time with isolated state. drove the actual web client with repository playwright and/usr/bin/google-chrome. created a project pointing to a real git checkout and a scheduled task using codexgpt-6.1-solthrough the app. no mocks, fixtures, or replay provider.- on main
61c3794c32, disabled codex in providers, then used scheduled tasks > actions > run now. the failed row displayedThreadManagementProviderInstanceDisabledError, server paths, and stack frames. - on the exact pr head with the same app-created data, repeated run now. the failed row displayed only
Provider instance "codex" is disabled for project 29f719ee-076e-4e4f-bc9e-b629e09d9c3b. - re-enabled codex and ran the same task. status became succeeded and the error cleared. the resulting real provider turn completed and rendered
SCHEDULED_RUN_OK. repeated failure and recovery successfully; both codex turns completed. pausing the task persisted after reload. - blacksmith:
vp test run apps/server/src/scheduledTasks/ScheduledTaskService.webhook.test.tspassed 57 tests.vp run check:changed 61c3794c32b0eeebfac09add43e403618c65d2d7passed format, lint, knip, graphql, typechecks, and 82 tests across 5 files.
before, main:

after, pr:



read-only runtime transcript records main's persisted stack, pr recovery with a null error, and completed codex turns. inspected all captures and checked uploaded video playback and seeking.
Not verified#
native ios/android and electron shells were not exercised on this linux web-client pass. live webhook delivery, automatic timer firing, bound-thread failures, interruption cleanup, and the mcp listing were not exercised; the real failure used manual run now and a disabled provider. existing automated webhook tests passed, but do not substitute for those live paths.
- on main
maria-rcks merged this741bcae
maria-rcks closed this
Sign in to join this conversation.
Approvability#
Verdict: Approved at
0d6d391Macroscope's review found this PR approvable — Failed scheduled runs now show the underlying error message rather than an internal stack trace. The change is confined to failure-status text and does not alter scheduling or execution behavior.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).