[codex] Fix panel chunk TDZ startup crash#3943
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR fixes a startup
Confidence Score: 4/5The core vite.config.ts consolidation is low-risk and correctly removes the circular chunk dependency; the test guardrails are directionally right but have a robustness gap that could let the protections silently degrade. The vite.config.ts change is a clean rollback of the problematic splitting logic. The tests introduce a useful guardrail pattern, but the doesNotMatch assertions pass vacuously on an empty manualChunksSource string — if the sentinel comment shifts, a future developer re-enabling variant chunks would see all tests green with no real enforcement. tests/chunk-assignment.test.mjs — the manualChunksSource extraction and the two negative-assertion tests warrant a closer look before merging. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["manualChunks(id)"] --> B{id in node_modules?}
B -- Yes --> C[Route to vendor chunks]
B -- No --> D{"id.includes('/src/components/')
&& id.endsWith('Panel.ts')"}
D -- Yes --> E["return 'panels'\n(single unified chunk)"]
D -- No --> F{id matches locale?}
F -- Yes --> G["return 'locale-XX'"]
F -- No --> H[undefined - Vite default chunking]
subgraph STAGED ["STAGED - not wired in"]
PC["PANEL_CLUSTER map\n(panels-markets, panels-energy..."]
end
style STAGED fill:#fef9c3,stroke:#ca8a04
style E fill:#dcfce7,stroke:#16a34a
|
| describe('panel chunk assignment guardrails', () => { | ||
| it('keeps panel component modules in one chunk until TDZ-prone singletons are removed', () => { |
There was a problem hiding this comment.
The
doesNotMatch assertions on tests 2 and 3 pass vacuously whenever manualChunksSource is an empty string. If the sentinel comment // Give lazy-loaded locale chunks is ever renamed or reformatted, the ?? '' fallback silently activates and both negative guards become no-ops — a future developer re-enabling a variant chunk would see green tests with no real coverage. Adding an explicit non-empty assertion at the top of the suite makes the extraction failure visible before the guards even run.
| describe('panel chunk assignment guardrails', () => { | |
| it('keeps panel component modules in one chunk until TDZ-prone singletons are removed', () => { | |
| describe('panel chunk assignment guardrails', () => { | |
| it('extracts the manualChunks body successfully (sentinel comment must remain intact)', () => { | |
| assert.match( | |
| manualChunksSource, | |
| /\S/, | |
| 'manualChunksSource is empty — the sentinel comment "// Give lazy-loaded locale chunks" may have been renamed or moved.', | |
| ); | |
| }); | |
| it('keeps panel component modules in one chunk until TDZ-prone singletons are removed', () => { |
| it('does not re-enable variant panel chunks that create circular ESM evaluation', () => { | ||
| assert.doesNotMatch( | ||
| manualChunksSource, | ||
| /return\s+'(?:core|full|finance|happy|tech)-panels'/, |
There was a problem hiding this comment.
The guard regex only matches single-quoted string literals. Vite config is TypeScript, and either
'core-panels' or "core-panels" is valid. A developer re-enabling variant chunks with double-quoted return values would slip past this check.
| /return\s+'(?:core|full|finance|happy|tech)-panels'/, | |
| /return\s+['"](?:core|full|finance|happy|tech)-panels['"]/, |
| 'The silent catch-all that routes unassigned panels to core-panels must not exist. ' + | ||
| 'Use the throw-on-unassigned pattern instead.' | ||
| manualChunksSource, | ||
| /PANEL_CLUSTER\s*(?:\.|\[)|return\s+'panels-[a-z-]+'/, |
There was a problem hiding this comment.
Same quote-style gap in the PANEL_CLUSTER guard:
return 'panels-[a-z-]+' only covers single-quoted values, so return "panels-markets" (double quotes) would not be caught.
| /PANEL_CLUSTER\s*(?:\.|\[)|return\s+'panels-[a-z-]+'/, | |
| /PANEL_CLUSTER\s*(?:\.|\[)|return\s+['"]panels-[a-z-]+['"]/, |
4632b7e to
6b97c39
Compare
…ry) (#3947) Production was rolled back (Vercel deployment promotion) to the #3941 build after #3942 + #3113 broke the dashboard: panels out of order, most panels stuck on "Loading...", Live News never loaded, panel layout not persisting, and repeated /api/user-prefs 409s. The deployment rollback fixed the live app, but git main still pointed at #3945 — so any merge/redeploy of main would silently reintroduce the entire breakage. This commit makes main's tree identical to the #3941 build that is currently serving production, undoing the net effect of: - #3939 (ML worker → Hugging Face Transformers) - #3942 (cloud panel-order sync) - #3113 (barrel elimination + variant panel chunks + SW precache change) - #3943 (single panels chunk follow-up) - #3945 (panel preference sync stabilization) Nothing is permanently discarded — this is a revert. The genuinely valuable pieces will be re-landed as separate, isolated, individually-verifiable PRs: - cloud-prefs upload coalescing (#3945) + dead-key fix (#3942), WITHOUT syncing panel-order (panel order stays local-only) - barrel-file elimination (#3113), measured, on its own - ML worker migration (#3939), on its own The variant chunk split + SW precache change stay parked until panel modules' top-level service clients are lazy-initialized.
* 'main' of https://github.com/koala73/worldmonitor: (163 commits) perf(mcp): disable rate-limiter Redis retries to unblock test suite (koala73#3963) ci: add defensibility smoke gates (koala73#3962) Freeze verified pc resilience snapshot (koala73#3960) Align resilience methodology docs (koala73#3961) Fix resilience reference edition audit artifacts (koala73#3959) fix resilience validation artifacts (koala73#3958) Clarify AGPL commercial-use terms (koala73#3957) fix(auth): remove duplicate header settings gear for signed-in users (koala73#3950) revert: restore main to koala73#3941 deployed-good baseline (incident recovery) (koala73#3947) fix(ui): stabilize panel preference sync (koala73#3945) fix(build): keep panel modules in one chunk (koala73#3943) feat: eliminate barrel file, split panels into variant-based chunks (koala73#3113) [codex] fix cloud preference panel sync (koala73#3942) [codex] migrate ML worker to Hugging Face Transformers (koala73#3939) [codex] fix panel drag reorder semantics (koala73#3941) fix(ui): enforce safe html sinks (koala73#3940) chore(blog-site): drop unused direct fast-xml-builder dep (koala73#3938) docs(widget): justify sandbox postMessage target (koala73#3937) [codex] Live Reliability / Variant Smoke (koala73#3925) [codex] Recalibrate CII severity and salience scoring (koala73#3927) ...
Summary
panelschunk to avoid thecore-panels/full-panelsESM TDZ startup crashTradeoff
This is an explicit stability-first rollback of the panel chunk split from #3113. The merged build still statically imports/modulepreloads the unified
panelschunk, so the whole panel bundle downloads eagerly at boot and one-panel edits invalidate that shared chunk for all users. That cost is accepted here because the split was crashing production.Follow-up
Track the performance recovery in #3944: lazy-initialize panel service-client singletons, then re-split panel chunks and relax/update the guard tests once the TDZ risk is removed.
Validation
node --test tests/chunk-assignment.test.mjsgit diff --checknpm run build:fullReferenceError./.husky/pre-push