fix(server): register Lingui message compiler to stop "Uncompiled message detected" log flood#21416
Open
machinagod wants to merge 1 commit into
Open
Conversation
…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>
Contributor
Welcome!
Hello there, congrats on your first PR! We're excited to have you contributing to this project. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #21415.
Server-side
t`…`macro calls (e.g.FlatEntityMapsException) resolve against Lingui's globali18nsingleton, whichI18nServicenever loads a catalog into and never registers a messages compiler on. With no_messageCompilerset, every such lookup logsUncompiled 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(notNODE_ENV-gated).Changes
Register
compileMessageviasetMessagesCompilerinI18nService.loadTranslations():i18nsingleton (used by thetmacro), and@lingui/message-utilsis 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 detectedlines/sec (saturating the log rate limit); after, steady-state shows0, and the worker (which shares the code path) likewise shows0. App behaviour is unchanged — messages already rendered via fallback; this silences the warning and enables ICU on the affected messages.