Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

5.6 KB
Raw Blame

Log noise: Lingui "Uncompiled message", react-pdf string children, opaque storage download errors

Three warnings/errors fire on hot paths in production (browser + server) and carry no signal.

1. Lingui "Uncompiled message detected!"

Cause. i18n._(x) with a plain string. Catalogs are compiled by @lingui/vite-plugin from .po with no explicit ids, so every key is generateMessageId(msgid) (a hash) — @lingui/format-po line 123. A plain-string lookup never matches, falls back to the string, and — because no runtime message compiler is installed — @lingui/core calls console.warn unconditionally (no NODE_ENV guard). So these calls never translated anything; they only cost a formatted warning per call, per render.

Inventory (type-checker driven: every i18n._ / i18n.t / t(...) whose argument type admits string, over the ERP and MES programs incl. workspace packages, strict null checks forced): 11 ERP sites, 0 MES.

Site Arg is Fix
components/Layout/Topbar/Breadcrumbs.tsx:72 entity readable ids + 15 literal handles pass strings through; literal handles → msg ``
components/Table/Table.tsx:306 column headers (already `t```) + "Actions"/"Expand"/"Collapse row"/"Expand row" drop helper; literals → t ``
components/Table/components/Columns.tsx:42 column headers drop helper
components/Table/components/Filter/Filter.tsx:85 filter headers / option helper text drop helper
components/Table/components/Filter/ActiveFilters.tsx:140 filter headers, option labels (data) drop helper
components/Table/components/TableHeader.tsx:171 saved-view name (data) / title (already `t```) drop helper
components/New.tsx:32 label (callers pass `t```; one literal) drop; literal caller → t ``
components/Form/CustomerStatus.tsx:38 customer status names (DB rows) render raw
modules/sales/ui/Customer/CustomerHeader.tsx:134 customer status name (DB) render raw
modules/sales/ui/CustomerStatuses/CustomerStatusesTable.tsx:28 status name (DB) render raw
modules/sales/ui/Customers/CustomersTable.tsx:64 status name (DB) render raw

Output is unchanged for every data string (the lookup always missed). The literal breadcrumbs / table sr-only labels / "IC Transaction" become real translations.

Guard. The Lingui warning itself: once these are gone it only fires on a real regression. No extra check.

  • Fix the 11 sites
  • pnpm lingui:extract: 3 new msgids (Collapse row, Expand row, IC Transaction), filled by hand in 12 locales from existing catalog terminology
  • Re-run the type-checker inventory → 0 hits (ERP + MES)

2. react-pdf "Invalid '' string child outside

Cause. {value && <Text>…</Text>} inside a <View> where value is "" (or a number 0) renders the raw value as a View child. Type-checker inventory (strict null checks forced — packages/documents is not strict, which is why TS never flagged it): 105 sites across 27 PDF files, mostly PartiesBlock/Header/Summary address lines.

Fix. Rewrite every {cond && <X/>} in packages/documents/src/pdf/** as {cond ? <X/> : null} (188 sites flagged by Biome, booleans included — uniform and behaviour-preserving). Fix remaining non-&& string children by hand (Note.tsx).

Guard. None added. Biome 2.3's nursery/noLeakedRender was tried and rejected: it is syntactic and also flags a && b ? <X/> : null (a && in a ternary TEST, which cannot leak) — 50 false positives after the rewrite. The react-pdf warning itself is the regression signal once the baseline is quiet.

  • Codemod && → ternary in packages/documents/src/pdf/** (186 sites, 38 files), then biome format
  • Non-&& leaks: the one remaining inventory hit (Note.tsx, ReactNode from the rich-text converter called on the doc root) is a false positive — bare text is only returned for text nodes, which render inside <Text>
  • Re-run PDF inventory → 0 hits; typecheck @carbon/documents

3. Storage "Failed to download file" with StorageUnknownError: {}

Cause. storage-js 2.80 download() passes noResolveJson: true, so a non-OK response (404, 400, 403) is wrapped as StorageUnknownError(JSON.stringify(Response)) = "{}"; the status only survives on error.originalError.status. The routes log neither path nor status, then sleep 1 s and repeat the whole download (company bucket + legacy fallback = 4 storage requests) before answering 404/500. The route-level retry is redundant: fetchWithRetry (packages/auth/src/lib/supabase/client.ts) already retries 5xx/408/524 and network errors with backoff for storage GETs.

Fix. storageErrorStatus(error) in @carbon/files (reads status / originalError.status). In the four copy-pasted routes — ERP + MES file+/preview+/$bucket.$.tsx, ERP file+/model+/public.$.tsx, share+/customer.$id.$.tsx — download once, log { path, status } once, 404 on a missing object, and drop the sleep-and-retry.

  • Helper + unit test in packages/files
  • Four routes. A miss (isStorageNotFound: a 404, or a 400 whose unread body says "statusCode":"404" — storage answers a missing object/bucket with 400 and uses 400 for an invalid key too) → 404; any other failure (5xx, auth, no status) → 500
  • Typecheck erp, mes, @carbon/files

Verification

  • scoped typechecks (one filter at a time)
  • @carbon/files tests; ERP Table/utils.test.ts
  • Browser: a part detail page + a table page show no "Uncompiled message" warnings; a PDF with an empty address line logs no string-child warning