[GH-ISSUE #2954] [Issue]: Legacy theme migration retries forever (and silently) if one theme can't be saved #1532

Closed
opened 2026-10-21 05:38:12 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @kolacheee on GitHub (Jun 28, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2954

Originally assigned to: @SpicyMarinara on GitHub.

What's wrong

The one-time migration that copies old localStorage themes onto the server POSTs each theme in a loop and only marks itself done if the whole loop succeeds. Its catch block swallows all errors silently (no toast, no log) and leaves the "migrated" flag unset — so if any single theme is persistently rejected by the server (e.g. a 400 from an invalid field), the whole migration re-runs its redundant GET + re-POST burst on every app start, forever. Deduplication prevents duplicate rows, so the symptom is a recurring pointless request burst rather than corruption — but it never stops on its own and gives no diagnostic. (The extension migration, by contrast, has a 429 backoff helper and at least logs.)

How to reproduce (try it yourself)

  1. In the browser devtools, seed localStorage with a legacy theme the server will reject — e.g. a customThemes entry whose name is an empty string (the create schema requires a non-empty name) — and set hasMigratedCustomThemesToServer to false.
  2. Reload the app, then reload again.

You'll see (Network tab): the full GET /themes + POST /themes burst repeats on every reload, with no toast or console warning, and the migrated flag never flips.
Expected: the migration backs off on transient errors and, on a permanent error, gives up (marks itself migrated, or surfaces a toast) instead of looping every boot.

Where it is

packages/client/src/hooks/use-themes.ts — useLegacyThemeMigration, lines 80-121: a direct api.post at line 96 (no backoff), a redundant api.get at 88, the flag set only after the full loop succeeds at 114, and a bare catch {} at 116 that swallows everything. Contrast use-extensions.ts postExtensionWithBackoff (lines 29-44), which retries on 429 and logs.

What's happening

No backoff was added for theme POSTs, and the catch leaves the flag unset on all errors (not just transient ones), so one un-postable theme traps the migration in an every-boot retry that can never complete.

Suggested fix

Mirror postExtensionWithBackoff for theme POSTs, distinguish transient (429/5xx → retry) from permanent (4xx → give up: mark migrated or surface a toast), and at least log on failure so a stuck migration is diagnosable.


AI-investigated against v2.0.6; cited lines read. Please confirm before fixing.

Originally created by @kolacheee on GitHub (Jun 28, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2954 Originally assigned to: @SpicyMarinara on GitHub. **What's wrong** The one-time migration that copies old localStorage themes onto the server POSTs each theme in a loop and only marks itself done if the **whole** loop succeeds. Its catch block swallows all errors silently (no toast, no log) and leaves the "migrated" flag unset — so if any single theme is persistently rejected by the server (e.g. a 400 from an invalid field), the whole migration re-runs its redundant `GET` + re-`POST` burst on **every app start, forever**. Deduplication prevents duplicate rows, so the symptom is a recurring pointless request burst rather than corruption — but it never stops on its own and gives no diagnostic. (The extension migration, by contrast, has a 429 backoff helper and at least logs.) **How to reproduce (try it yourself)** 1. In the browser devtools, seed `localStorage` with a legacy theme the server will reject — e.g. a `customThemes` entry whose `name` is an empty string (the create schema requires a non-empty name) — and set `hasMigratedCustomThemesToServer` to `false`. 2. Reload the app, then reload again. **You'll see** (Network tab): the full `GET /themes` + `POST /themes` burst repeats on every reload, with no toast or console warning, and the migrated flag never flips. **Expected:** the migration backs off on transient errors and, on a permanent error, gives up (marks itself migrated, or surfaces a toast) instead of looping every boot. **Where it is** `packages/client/src/hooks/use-themes.ts` — `useLegacyThemeMigration`, lines 80-121: a direct `api.post` at line 96 (no backoff), a redundant `api.get` at 88, the flag set only after the full loop succeeds at 114, and a bare `catch {}` at 116 that swallows everything. Contrast `use-extensions.ts` `postExtensionWithBackoff` (lines 29-44), which retries on 429 and logs. **What's happening** No backoff was added for theme POSTs, and the catch leaves the flag unset on **all** errors (not just transient ones), so one un-postable theme traps the migration in an every-boot retry that can never complete. **Suggested fix** Mirror `postExtensionWithBackoff` for theme POSTs, distinguish transient (429/5xx → retry) from permanent (4xx → give up: mark migrated or surface a toast), and at least log on failure so a stuck migration is diagnosable. --- *AI-investigated against v2.0.6; cited lines read. Please confirm before fixing.*
Author
Owner

@SpicyMarinara commented on GitHub (Jun 28, 2026):

Fixed on staging: legacy theme migration now uses bounded retry/backoff for transient errors, skips permanent rejected entries with diagnostics, and marks migration complete once recoverable work is done.

<!-- gh-comment-id:4827785058 --> @SpicyMarinara commented on GitHub (Jun 28, 2026): Fixed on staging: legacy theme migration now uses bounded retry/backoff for transient errors, skips permanent rejected entries with diagnostics, and marks migration complete once recoverable work is done.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#1532
No description provided.