Skip to content

fix(server): register Lingui message compiler to stop "Uncompiled message detected" log flood#21416

Open
machinagod wants to merge 1 commit into
twentyhq:mainfrom
machinagod:fix/i18n-uncompiled-message-warning
Open

fix(server): register Lingui message compiler to stop "Uncompiled message detected" log flood#21416
machinagod wants to merge 1 commit into
twentyhq:mainfrom
machinagod:fix/i18n-uncompiled-message-warning

Conversation

@machinagod

Copy link
Copy Markdown

Summary

Fixes #21415.

Server-side t`…` macro calls (e.g. FlatEntityMapsException) resolve against Lingui's global i18n singleton, which I18nService never loads a catalog into and never registers a messages compiler on. With no _messageCompiler set, every such lookup logs Uncompiled message detected! and falls back to the raw string — flooding server logs (enough to hit hosting log rate limits) and disabling ICU interpolation on those messages. The warning is emitted unconditionally by @lingui/core (not NODE_ENV-gated).

Changes

Register compileMessage via setMessagesCompiler in I18nService.loadTranslations():

  • on the global i18n singleton (used by the t macro), and
  • on each per-locale instance.

@lingui/message-utils is already a transitive runtime dependency of @lingui/core (@lingui/core@5.1.2 → @lingui/message-utils@^5.1.2), so no new dependency is added.

Testing

Deployed on a real instance: before, the server emitted hundreds of Uncompiled message detected lines/sec (saturating the log rate limit); after, steady-state shows 0, and the worker (which shares the code path) likewise shows 0. App behaviour is unchanged — messages already rendered via fallback; this silences the warning and enables ICU on the affected messages.

…sage detected" log flood

Server-side `t`…`` macro calls (e.g. exception messages such as
FlatEntityMapsException) resolve against Lingui's global i18n singleton, which
the I18nService never loads a catalog into. With no messages compiler registered,
every such lookup logs "Uncompiled message detected! Please compile your catalog
first." and falls back to the raw string. In a running server this floods logs
(enough to hit hosting-provider log rate limits) and disables ICU interpolation
on those messages. The warning is emitted by @lingui/core unconditionally — it is
not gated by NODE_ENV.

Register `compileMessage` via `setMessagesCompiler` on the global i18n singleton
(used by the `t` macro) and on each per-locale instance. `@lingui/message-utils`
is already a transitive runtime dependency of `@lingui/core`, so no new dependency
is introduced.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 1 file

Re-trigger cubic

@github-actions

Copy link
Copy Markdown
Contributor

Welcome!

Hello there, congrats on your first PR! We're excited to have you contributing to this project.
By submitting your Pull Request, you acknowledge that you agree with the terms of our Contributor License Agreement.

Generated by 🚫 dangerJS against f4a0ea8

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.

Server floods logs with "Uncompiled message detected" from Lingui on every t call

1 participant