Skip to content

bug(i18n): a topic that lands late misses memoised labels, and reading other languages once makes later chunks wait for them #4433

Closed

Description

@yannickmonney

Summary

c90f244a9e introduced per-topic message loading in packages/ui, and 8b750caf30 wired it into the platform. Both were pushed directly to main on 2026-10-06. The loading has two defects.

A. A topic that lands after the 4 s wait leaves memoised labels in English

  • What happens:
    • useT hands out one t per language and namespace (packages/ui/src/i18n/client.tsx:120-126).
    • It re-renders its readers when their namespace's messages land (:39-43), but it never replaces t.
    • So a label computed in useMemo(…, [t]) keeps the fallback, English, after the topic lands. It stays that way until the component remounts or the language changes.
  • Example: the granularity and metric options at services/platform/app/features/analytics/usage/usage-metrics-page.tsx:107-122. Code search finds about 40 platform files with a useMemo over [t].
  • Trigger: in a de, fr or de-CH session, the topic of a chunk loaded on demand takes longer than the chunk's 4 s wait (packages/ui/src/i18n/topics.ts:168-181). It can also fail once and then be fetched again by ensure (:183-198). The page then renders in English, and when the topic lands only the labels that aren't memoised switch language.
  • Which claim breaks: c90f244a9e says "a late topic replaces the fallback instead of staying".
  • Tests: client.test.tsx:58 asserts that t stays the same across renders, and no test covers a memoised reader.

B. Loading another language once makes every later chunk wait for it

  • What happens:
    • TopicRegistry.load(locale) adds that locale's files to following (topics.ts:152-155).
    • Only a languageChanged event resets following (:162-165, :248-250).
  • Trigger: the governance data-notice editor reads every language through useLocalesLoaded(['en','de','fr']), and useLocalesLoaded (packages/ui/src/i18n/load-locale.ts:126-149) calls loadLocale for de and for fr.
  • Effect after an English session opens that editor:
    • Every topic registered from then on is also fetched in de and fr (register, topics.ts:88-93).
    • Every chunk loaded on demand waits for those files in ready (:168-181, up to 4 s each). Before, it waited for nothing.
    • Each of those load() calls also fetches every registered topic in that language, not just the topic the editor needs.
  • The same leak: switch to fr, and before fr has loaded, switch back to de. No languageChanged fires, because the shown language is still de, so fr stays followed.

Source and environment

  • Commits: main at dac9bf2fcf46b1fd3936859eb94ecb1ce583bd22. These files are unchanged at 9bd1e2015d.
  • How it was found: by reading the code. Nothing was run in a browser, and no benchmark was run.

Expected

  • A: when a reader's namespace lands in its language, the reader sees a new t or snapshot, so memoised labels recompute.
  • B: ready and register follow only the language the session shows. Reading other languages through useLocalesLoaded doesn't change what later chunks fetch or wait for.

Related

#4421 covers the same loading path but a different defect: the Language menu while a catalog is loading or has failed.

Limits

Read-only post-merge review. Nothing was run.

Found in the TALE-965 post-merge review of 890de625..dac9bf2fcf (main after v0.5.74, slice 1).

Activity

  1. added
    perf
    bug
    service: platform
    on Oct 6, 2026
  2. added
    agent-ready
    on Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readybugperfservice: platform

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions