Skip to content

fix(web): container ENV vars unreliably applied due to startup race#972

Merged
PartyDonut merged 1 commit intoDonutWare:developfrom
v3DJG6GL:fix/config-load-race
Apr 28, 2026
Merged

fix(web): container ENV vars unreliably applied due to startup race#972
PartyDonut merged 1 commit intoDonutWare:developfrom
v3DJG6GL:fix/config-load-race

Conversation

@v3DJG6GL
Copy link
Copy Markdown
Contributor

Pull Request Description

Container ENV vars (BASE_URL, SEERR_BASE_URL, etc.) stopped being applied reliably on my Container/WebUI deployment. After some researching, I found PR #805 which seems to introduce a regression:

The behaviour I see is inconsistent: sometimes the login screen reflects the ENV vars (Jellyfin URL/Seerr URL ENV vars set -> both URL field hidden from UI, etc.), sometimes it doesn't - the Jellyfin URL field reappears Seerr URL field is configurable, and so on. A page refresh makes it fail much more often, but it can also go wrong on the very first load.


Possible Regression

Before #805, config.json was loaded in main() before the app started. So by the time any screen rendered, the config was guaranteed ready.

After #805, the load was moved into a post-frame callback on the web wrapper. That callback is async, but Flutter's post-frame queue doesn't wait for async work to finish. So LoginScreen's own post-frame callback runs in the same tick and reads the still-empty config singleton.

It's a timing race: whoever finishes first wins. The ~500ms SplashScreen delay usually hides it on cold loads (the network fetch has time to resolve), but on a refresh everything is served from the cache in milliseconds and the race is lost almost every time. On first loads it can still go wrong whenever the config fetch happens to be slow enough.


Fix

Restore the pre-#805 behaviour: Load config.json inside bootstrapApplication, awaited before runApp. By the time any widget's initState runs, FladderConfig is guaranteed populated.


Issue Being Fixed

Regression from #805.


How To Reproduce (before this fix)

  1. Run the Docker image with e.g. BASE_URL=https://jellyfin.DOMAIN.TLD
  2. Open the web UI → Jellyfin URL field may or may not be hidden depending on timing
  3. Refresh the page (F5) → usually the Jellyfin URL field comes back (race almost always lost once the service worker is primed)

After applyint this PR, the UI state is consistent across cold loads and refreshes.


Screenshots

N/A

Notes

AI Disclosure

Diagnosed and fixed with assistance help from Claude Code (Opus 4.7). The LLM helped me trace the init sequence.
I've reviewed and tested the fix end-to-end.

Tested On

  • Android
  • Android TV
  • iOS
  • Linux
  • Windows
  • macOS
  • Web

Checklist

  • If a new package was added, did you ensure it works for all supported platforms?
  • Check that any changes are related to the issue at hand.

Copy link
Copy Markdown
Collaborator

@PartyDonut PartyDonut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, and thanks for fixing it!

@PartyDonut PartyDonut added the bug Something isn't working label Apr 28, 2026
@PartyDonut PartyDonut merged commit 6e9066d into DonutWare:develop Apr 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants