fix(web): enable Next.js version skew protection during rolling deploys#1346
Conversation
Set `deploymentId` from the commit sha already baked in at build time (NEXT_PUBLIC_BUILD_COMMIT_SHA). Next.js stamps static asset URLs with ?dpl=<sha> and, on a deployment-id mismatch during navigation, does a full reload instead of fetching chunks from a build that's no longer serving — fixing the "Failed to load chunk" error users hit while the pod is updating. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Caution Review failedPull request was closed or merged during review No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
Walkthrough
ChangesNext.js version-skew protection
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
This comment has been minimized.
This comment has been minimized.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Problem
During a Sourcebot pod update, users sometimes see an
Unexpected Errorscreen withFailed to load chunk /_next/static/chunks/<hash>.js. This is Next.js client/server version skew: a browser holding an old build's HTML/runtime requests a content-hashed chunk that the newly-rolled pod no longer serves (especially sharp atreplicaCount: 1, where the old pod is gone entirely after the rollout). The zero-downtime rollout config handles connection-level downtime (502s) but not stale assets already in a user's browser.Fix
Enable Next.js version skew protection by setting
deploymentIdinnext.config.mjs, sourced fromNEXT_PUBLIC_BUILD_COMMIT_SHA— a per-build, build-time-stable value already plumbed through theDockerfileand_build.yml(github.sha).With this set, Next.js:
?dpl=<sha>, andSo a user on an old build silently reloads onto the new build instead of hitting the error screen.
Notes
NEXT_PUBLIC_BUILD_COMMIT_SHAis passed); localpnpm buildleaves itundefined, which harmlessly leaves skew protection inactive.🤖 Generated with Claude Code
Summary by CodeRabbit