Skip to content

fix(language): discard stale loadLanguage fetches#29

Open
lukyrys wants to merge 1 commit intomainfrom
fix/lang-race
Open

fix(language): discard stale loadLanguage fetches#29
lukyrys wants to merge 1 commit intomainfrom
fix/lang-race

Conversation

@lukyrys
Copy link
Copy Markdown
Collaborator

@lukyrys lukyrys commented May 5, 2026

Race in frontend/src/scripts/language.ts: rapid currentLanguage.set() calls during startup ('en'initLanguage() 'cs' → backend 'cs') fired parallel loadLanguage() fetches; if en.json resolved after cs.json, EN translations stomped CS ones. Symptom: random EN UI when CZ was selected.

Extracted createTranslationLoader() with pendingLangID guard — fetch results that no longer match the latest target are discarded. Top-level subscribe + initLanguage() gated behind typeof window so unit tests don't fire spurious fetches.

5 unit tests under bun test, @types/bun added, new test script. svelte-check clean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant