Skip to content

fix(dev): the runner says which migration failed - #694

Merged
allisonmahmood merged 2 commits into
mainfrom
fix/186-dev-runner-migration-error
Oct 15, 2026
Merged

allisonmahmood merged 2 commits into
mainfrom
fix/186-dev-runner-migration-error

Conversation

@allisonmahmood

Copy link
Copy Markdown
Owner

When a migration failed on the way up, pnpm dev said only "The supervisor exited before the server became healthy" and dev.log had no [dev] line saying why. A step's SQL error is a defect in Effect's Migrator, so the supervisor's tapError never saw it, and a duplicate id was logged as "Found duplicate migration id's" without the id.

Fix

  • The supervisor logs any migrate failure (not an interrupt) to dev.log as a marked [dev] error: line, worded like the seed's error: The dev database failed to migrate: <step>: <Postgres's reason>.
  • When the supervisor dies before the server is healthy, start reads that line from the supervisor's own run (between its supervisor pid= line and the next run's, so another run's failure is never shown) and prints it, then points at dev.log. If there's no such line, it prints the old message.
  • @patchy/sql's loader names a duplicate id and both steps that claim it. The server's own migrate gets the clearer message too.

Seed and package-build failures still go only to the supervisor's ignored stderr. That's the same kind of gap, but it's a separate change.

Tested by hand

pnpm dev up in this worktree with a migration temporarily broken, before and after (paths shortened):

Duplicate id 14 (a second 0014_… step in @patchy/limits)

Before:

The supervisor exited before the server became healthy; see /home/you/patchy-cloud/.local/dev/dev.log.
[dev] postgres pid=… port=…
[dev] Found duplicate migration id's
[dev] postgres stopped

After:

The dev database failed to migrate: Migration id 14 is used twice, by "runtime_calls_machine" and "dup_probe". Nothing was applied.
See /home/you/patchy-cloud/.local/dev/dev.log.
[dev] postgres pid=… port=…
[dev] error: The dev database failed to migrate: Migration id 14 is used twice, by "runtime_calls_machine" and "dup_probe". Nothing was applied.
[dev] postgres stopped

A failing step (0015_broken_probe: SELECT * FROM no_such_table)

Before: the same generic terminal line, and in dev.log only Postgres's own ERROR: relation "no_such_table" does not exist, with no [dev] line naming the migration.

After:

The dev database failed to migrate: Migration "15_broken_probe" failed: relation "no_such_table" does not exist
See /home/you/patchy-cloud/.local/dev/dev.log.
[dev] error: The dev database failed to migrate: Migration "15_broken_probe" failed: relation "no_such_table" does not exist
[dev] postgres stopped

With the break reverted, pnpm dev up still comes up healthy (scenario team), and pnpm dev down cleans it up.

Tests: a duplicate-id case in packages/sql/src/sql.test.ts, and a failureOf case in scripts/dev/src/state.test.ts.

Surfaces

  • Dev loop: applied. docs/DEVELOPMENT.md (the migration paragraph under "The local instance") and the patchy-dev-loop skill now say a failed migration prints which step failed and why. The vitest template is untouched because the seed didn't change.
  • Migrations: no new migration. The loader's duplicate refusal now names the id, and the migrate doc comment says so.
  • Wire contract, CLI, vocabulary, company resources, served pages, reverse states, repo layout: don't apply.

Closes #186

Made by Claude Opus 5.5 in Claude Code, running in T3 Code.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Review by GPT 6.1 Sol (codex, xhigh, one pass) on 136d7c1. Two findings, both fixed in f820aab:

  • Medium, scripts/dev/src/state.ts failureOf read to EOF. A retry started before the first pnpm dev read dev.log could lend it the newer run's error. Fixed: the scan now stops at the next [dev] supervisor pid= header, and the test checks an older pid after a newer run has logged its own failure.
  • Low, scripts/dev/src/supervisor.ts multi-line messages. A reason containing a newline would be cut short in the terminal and leave unprefixed lines in dev.log. Fixed: reasonOf folds newlines into spaces. I skipped the separate multi-line unit test Sol suggested. reasonOf is private to the supervisor module, and importing that module's dependency graph made a pure-function test take ~34s, all for a one-line replace. The hand reproduction in the description exercises reasonOf on a real Migrator cause chain.

@github-actions github-actions Bot added area:server Touches the server area area:ci CI, shared testing infrastructure, development scripts and tooling area:docs Touches the docs area size:m 100-500 changed lines labels Oct 15, 2026
A migration that failed on the way up left `pnpm dev` saying only that the
supervisor exited: a step's SQL error is a defect in the Migrator, which the
supervisor's tapError never saw, and a duplicate id was reported without the id.

The supervisor now logs any migrate failure to dev.log as a marked `[dev] error:`
line with the step and Postgres's reason, and `start` prints that line from the
supervisor's own run. The sql package's loader names a duplicate id and both
steps that claim it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
failureOf stops at the next supervisor's header, so a retry started before
the first caller reads dev.log cannot lend it its error, and the reason is
folded onto one line so the marked line carries all of it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@allisonmahmood
allisonmahmood force-pushed the fix/186-dev-runner-migration-error branch from f820aab to 69f6dee Compare October 15, 2026 20:34
@allisonmahmood
allisonmahmood merged commit ba9b46a into main Oct 15, 2026
13 checks passed
@allisonmahmood
allisonmahmood deleted the fix/186-dev-runner-migration-error branch October 15, 2026 20:44
allisonmahmood added a commit that referenced this pull request Oct 16, 2026
…u when they fail (#720)

Release 13's What's new entry, written from `c9b8fc4`, ahead of
deploying it. `patchy` and `CURRENT_RELEASE` move to `0.13.0`, so CLIs
and patch repos installed before this deploy are told to upgrade.

| Change | PRs |
| --- | --- |
| New: Home puts the patches you use first | #713, #716, #719 |
| New: Every patch in one list | #715 |
| Improved: Each patch's page leads with Open | #717 |
| New: See when your tools are failing | #718 |
| Fixed: Everyone has a name | #687 |
| Improved: Your company's look is easier to get right | #697, #696,
#703, #688 |
| Improved: Forms follow your look's error states | #691, #692 |
| Improved: Clearer answers when a publish goes wrong | #686, #685, #689
|
| Fixed: Your agent's Patchy commands are steadier | #695, #704, #680,
#681 |
| Behind the scenes: stricter checks on static pages and tools' database
requests; malformed requests are logged | #682, #693, #683 |
| Behind the scenes: usage numbers count every publish, sharing change
and restore | #698, #699, #700, #690 |
| Test and tooling only, no line | #705, #702, #701, #694, #684, #607 |

Made by Claude Opus 5.5 in Claude Code, running in T3 Code.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ci CI, shared testing infrastructure, development scripts and tooling area:docs Touches the docs area area:server Touches the server area size:m 100-500 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dev runner: a failed migration is silent

1 participant