Problem: Next.js server caches BUILD_ID at startup. If .next/ is rebuilt mid-cycle, HTML references stale JS/CSS hashes. User gets blank page. Happened twice today.
Solution:
- Post-start live verification in start.sh - curl page, verify all referenced JS/CSS return 200 AND CSS hash in HTML matches disk
- Stale-build detection on startup - compare BUILD_ID in compiled server bundles vs .next/BUILD_ID
- Enhanced 30-min cron - also compare BUILD_ID in live RSC payload vs disk
- Unit test for verify-build.sh - test hash mismatch detection
- Document lessons
reviewState: done
reviewRequested: false
completedAt: '2026-05-09T22:50:00+08:00'
completion_note: >
All items completed:
- β
Post-start live verification in start.sh (curl + verify JS/CSS 200 + CSS hash match) β already present
- β
Stale BUILD_ID detection on startup β already present
- β
Enhanced 30-min cron β updated OpenClaw cron job to use check-build-consistency.sh (BUILD_ID, CSS hash, chunk 200 checks) instead of basic verify-build.sh live. Systemd timer mc-build-consistency.timer also runs the full check
- β
Unit tests for verify-build.sh β already present in tests/verify-build.test.ts (covers dir, stale, live, CSS hash, BUILD_ID mismatch)
- β
Document lessons β added F9 Stale-server loop section to FAILURE-HANDLING.md