Skip to content

fix(desktop): a slow database migration no longer counts as a failed start - #235

Merged
badcuban merged 1 commit into
mainfrom
feat/desktop-waits-for-migrations
Sep 6, 2026
Merged

fix(desktop): a slow database migration no longer counts as a failed start#235
badcuban merged 1 commit into
mainfrom
feat/desktop-waits-for-migrations

Conversation

@badcuban

@badcuban badcuban commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator

The desktop treats a backend that has not answered within 60 seconds of a first launch as dead and kills it. But the SQLite driver is synchronous: while a long migration statement runs, the backend cannot answer HTTP, log, or heartbeat, so healthy work looked identical to a hang. The kill rolled the migration back and Try Again started it over. That is how nightly .275 left the app stuck at "Threadlines couldn't start" on large databases (#234 fixes that migration; this PR fixes the next one).

Two changes:

  • The server logs each migration as it starts and finishes, with its duration. Today the log says "Running all migrations..." and then nothing, so the slow one was not attributable.
  • At the readiness deadline the desktop looks at the backend output it already captures. If a migration started and has not reported finishing, it keeps probing without a deadline and shows a plain info box: "Threadlines is updating its data. Database update 50 of 51 is still running. Large histories can take several minutes, and Threadlines opens on its own when it finishes. Quitting now is safe. The update starts over next time." Buttons are Keep Waiting and Quit. The box closes itself when the backend answers or the run ends. With no unfinished migration in the output, the 60-second kill and the failure dialog are unchanged.

The two log prefixes live in contracts so the writer and the reader cannot drift apart. Message boxes now receive the fiber's abort signal through the shared Electron dialog wrapper, so any dialog closed by interruption goes away instead of lingering.

Tests: one new desktop test covers the keep-waiting path end to end (deadline passes mid-migration, no kill, notice shown, backend answers, notice closed, window opens). The existing readiness-timeout test now includes a finished migration in the output, proving a completed migration does not buy a hung backend extra time.

…start

The desktop kills a backend that has not answered its readiness probe
within 60 seconds of a first launch. The SQLite driver is synchronous, so
a backend inside a long migration statement cannot answer anything, and
it looked exactly like a hung process: the run was killed, the migration
transaction rolled back, and "Try Again" repeated the same work forever.
That is how nightly .275 bricked startup on large databases (#234).

The server now logs each migration as it starts and finishes, with its
duration, using two message prefixes shared through contracts. At the
readiness deadline the desktop reads its captured backend output: if a
"Running migration" line has no matching "Finished migration" line, it
keeps probing without a deadline and shows a small info box saying which
database update is running, with Keep Waiting and Quit. The box closes on
its own when the backend answers or the run ends. Without an unfinished
migration the 60-second kill is unchanged. Message boxes now receive the
fiber's abort signal, so an interrupted dialog closes instead of lingering.
@vercel

vercel Bot commented Sep 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
threadlines Skipped Skipped Sep 6, 2026 4:42am UTC

Request Review

@github-actions github-actions Bot added size:L vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels Sep 6, 2026
@badcuban
badcuban added this pull request to the merge queue Sep 6, 2026
Merged via the queue into main with commit 84bb34c Sep 6, 2026
16 checks passed
@badcuban
badcuban deleted the feat/desktop-waits-for-migrations branch September 6, 2026 04:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant