Skip to content

Fix chunk loading issues#712

Merged
feruzm merged 2 commits into
developfrom
chunk
Mar 22, 2026
Merged

Fix chunk loading issues#712
feruzm merged 2 commits into
developfrom
chunk

Conversation

@feruzm
Copy link
Copy Markdown
Member

@feruzm feruzm commented Mar 22, 2026

Summary by CodeRabbit

  • New Features

    • Automatic client-side recovery from asset/chunk loading failures to reduce broken pages after updates.
  • Chores

    • More robust deployment process and network handling to reduce failed deploys.
    • Longer graceful shutdown and controlled rolling updates/rollbacks for smoother, less disruptive releases.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 22, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a3d2fe0c-58c2-41ab-a8b5-4f3078f5fb38

📥 Commits

Reviewing files that changed from the base of the PR and between 0ce662a and 7f174f4.

📒 Files selected for processing (1)
  • apps/web/public/scripts/chunk-reload.js

📝 Walkthrough

Walkthrough

Updates add a client-side chunk-reload recovery script and include it in the app layout; adjust Docker Compose to set graceful shutdown and controlled rolling updates/rollbacks for the web service; and modify GitHub Actions deployment workflows to ensure the overlay network exists non-fatally, add a fixed post-deploy pause, and move system prune to after deployment.

Changes

Cohort / File(s) Summary
GitHub Workflows
.github/workflows/master.yml, .github/workflows/staging.yml
Deployment steps now create the overlay network vision with a non-fatal `
Docker Compose Configurations
apps/web/docker-compose.yml, apps/web/docker-compose.production.yml
web service gains stop_grace_period: 30s. deploy now includes update_config (parallelism: 1, delay: 15s, order: start-first, failure_action: rollback, monitor: 30s) and rollback_config (parallelism: 1, order: start-first).
Client-side Chunk Recovery
apps/web/public/scripts/chunk-reload.js, apps/web/src/app/layout.tsx
Adds a new script that listens for chunk-load failures (error and unhandledrejection) and triggers guarded reloads (sessionStorage or _cr query fallback). Layout imports the script before config-stub.js.

Sequence Diagram(s)

sequenceDiagram
  participant CI as CI Runner
  participant SSH as Remote Host (SSH)
  participant Docker as Docker Engine / Swarm
  CI->>SSH: SSH + run deploy script
  SSH->>Docker: docker network create --driver overlay vision || true
  SSH->>Docker: docker pull <image>
  SSH->>Docker: docker stack deploy ...
  SSH->>SSH: sleep 60
  SSH->>Docker: docker system prune -f
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰
When chunks slip off the changing road,
I nudge the page back to its code,
Two tries, a guard, a gentle hop,
While Docker waits a counted stop,
We roll, we patch, then softly goad.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix chunk loading issues' directly addresses the main change: adding chunk-reload.js and Docker deployment configurations to handle and recover from chunk loading failures during deployments.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chunk

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can suggest fixes for GitHub Check annotations.

Configure the reviews.tools.github-checks setting to adjust the time to wait for GitHub Checks to complete.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
.github/workflows/staging.yml (1)

115-117: Network creation safeguard looks good.

The || true idiom correctly handles the case where the network already exists.

Consider adding the sleep 60 and docker system prune -f pattern from master.yml for consistency, though this may be less critical for staging:

💡 Optional: Align with master.yml deployment pattern
          docker network create --driver overlay vision || true
          docker pull ecency/vision-next:develop
          docker stack deploy -c <(docker-compose config) vision
+          sleep 60
+          docker system prune -f
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/staging.yml around lines 115 - 117, Add the same
post-pull/pre-deploy housekeeping used in master.yml by inserting a short pause
and a cleanup step after the image pull and before docker stack deploy: after
the docker pull ecency/vision-next:develop command, run a sleep 60 to allow the
image layer propagation and then run docker system prune -f to remove unused
data; keep the existing docker network create --driver overlay vision || true
and then run docker stack deploy -c <(docker-compose config) vision as-is.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/web/public/scripts/chunk-reload.js`:
- Around line 26-29: The catch block currently falls through to
window.location.reload() which can cause an infinite reload loop if
sessionStorage is unavailable; modify the logic inside the catch to detect and
set a one-time guard using a URL parameter (e.g., check for a "chunkReloaded"
query param) or an in-memory flag so that the reload is only performed once, and
when reloading append/replace the URL with that param (or skip reload if it's
already present); update the code paths around sessionStorage access and the
window.location.reload invocation to honor this guard and avoid repeated
reloads.

---

Nitpick comments:
In @.github/workflows/staging.yml:
- Around line 115-117: Add the same post-pull/pre-deploy housekeeping used in
master.yml by inserting a short pause and a cleanup step after the image pull
and before docker stack deploy: after the docker pull ecency/vision-next:develop
command, run a sleep 60 to allow the image layer propagation and then run docker
system prune -f to remove unused data; keep the existing docker network create
--driver overlay vision || true and then run docker stack deploy -c
<(docker-compose config) vision as-is.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8ca83e9c-ed8e-4418-806a-dc894ee8f793

📥 Commits

Reviewing files that changed from the base of the PR and between 0c9e67d and 0ce662a.

📒 Files selected for processing (6)
  • .github/workflows/master.yml
  • .github/workflows/staging.yml
  • apps/web/docker-compose.production.yml
  • apps/web/docker-compose.yml
  • apps/web/public/scripts/chunk-reload.js
  • apps/web/src/app/layout.tsx

Comment thread apps/web/public/scripts/chunk-reload.js Outdated
@feruzm feruzm merged commit 814390d into develop Mar 22, 2026
1 check was pending
@feruzm feruzm deleted the chunk branch March 22, 2026 08:51
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.

1 participant