fix(deploy): force-upload Mermaid runtime to S3 + add pre/post-deploy guards#2681
Merged
Conversation
… guards `aws s3 sync --include '*.mjs' --size-only` was silently skipping the deeply-nested chunk files under `dist/js/lib/mermaid/chunks/mermaid.esm.min/`, leaving CloudFront serving 403s for ~80 chunks while the entry module `mermaid.esm.min.mjs` returned 200. Browsers then fail the whole module graph with `Failed to fetch dynamically imported module: …mermaid.esm.min.mjs` (error attributed to the parent module), so every article with Mermaid diagrams renders without them. Fix is defensive: 1. scripts/deploy-s3.sh: add unconditional `aws s3 cp --recursive` pass for `dist/js/lib/mermaid/*.mjs` with explicit `application/javascript` content-type and the same long-lived immutable cache-control as the per-type sync. Placed AFTER per-type sync and BEFORE orphan cleanup so headers stick and cleanup sees the keys as in-sync. 2. .github/workflows/deploy-s3.yml: assert ≥50 chunks staged in `dist/js/lib/mermaid/chunks/mermaid.esm.min/` BEFORE deploy (fails fast on a broken vendor copy), and HEAD-probe the entry + first chunk on S3 (direct, bypassing CloudFront) AFTER deploy so a recurrence is caught before the next nightly news-* run publishes articles that won't render. Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
pethers
May 22, 2026 15:36
View session
Contributor
🏷️ Automatic Labeling SummaryThis PR has been automatically labeled based on the files changed and PR metadata. Applied Labels: workflow,ci-cd,deployment,refactor,size-m Label Categories
For more information, see |
Contributor
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
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.
Articles embedding Mermaid diagrams (e.g.
2026-05-22-committee-reports-en.html) render blank with:Root cause
Browser attributes the failure to the top-level URL, but the actual 4xx is on the entry module's nested static imports:
/js/lib/mermaid/mermaid.esm.min.mjs(entry)/js/lib/mermaid/chunks/mermaid.esm.min/chunk-*.mjs(~80 files)Verified against deploy run
26294355929:copy-vendor-mermaid.tsstages 82 chunks intojs/,cp -r js/* dist/js/copies them intodist/,minify-dist.tscorrectly skipsjs/lib/mermaid— butscripts/deploy-s3.sh's per-typeaws s3 sync --include '*.mjs' --size-onlypass uploaded zero.mjsfiles despite the chunks being absent from S3. The subsequent--delete --size-onlyorphan pass also uploaded nothing. Reproducing the exactsyncdecision in the sandbox without AWS creds is non-trivial, so the fix is defensive rather than a filter tweak.Changes
scripts/deploy-s3.sh— unconditionalaws s3 cp --recursivepass fordist/js/lib/mermaid/*.mjsbetween per-type sync and orphan cleanup.cpdoesn't size-compare, so the chunks are guaranteed to upload regardless of whatsyncdecides. Sameapplication/javascript+public, max-age=31536000, immutableheaders as the per-type sync, so cache behavior is unchanged..github/workflows/deploy-s3.yml— two guards so a recurrence fails the workflow instead of silently shipping:cp -r js/* dist/js/): entry exists and chunks dir has ≥50.mjsfiles.Runtime payload (~2.6 MB, 82 chunks) only changes on Mermaid version bumps, so the always-upload cost is negligible vs. the cost of articles silently rendering without diagrams.