Preview tool: Playwright browser serves stale JS cache across preview_stop/start cycles
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
The Preview tool's built-in Playwright browser persistently serves stale/cached JavaScript bundles even after the Next.js dev server is fully stopped, .next directory is deleted, and the server is restarted from scratch.
The compiled JS files on disk are correct and updated, but the Preview browser continues to load old versions. The user's real browser (Chrome) shows the correct updated code at the same time — only the Preview tool's browser is affected.
What Should Happen?
When the dev server is stopped, .next is deleted, and the server is restarted fresh, the Preview browser should load the newly compiled JavaScript — not a cached version from a previous session.
Error Messages/Logs
No error messages shown. Silent failure — Preview browser fetches stale JS silently.
Evidence:
File on disk (correct):
wc -c .next/dev/static/chunks/src_618205f8._.js → 102283 bytes
grep -c "adTr" → 10 matches
Preview browser fetch (stale):
fetch('/_next/static/chunks/src_618205f8._.js').text().length → 77686 bytes
(text.match(/adTr/g) || []).length → 0 matches
DOM confirms old code:
labels: ["Nom (TR) *", "Description", "Couleur"] ← OLD
inputs: ["ad", "aciklama", "renk", "text"] ← OLD
Chrome browser shows correct updated code simultaneously.
Steps to Reproduce
- Start dev server via
preview_start(e.g., name: "flow-dev", port: 3444) - Navigate to a page and verify it loads correctly
- Edit a source file (e.g., change a form layout significantly)
- Stop the preview:
preview_stop - Kill remaining process:
lsof -ti :3444 | xargs kill -9 - Delete .next completely:
rm -rf .next - Verify deletion:
ls .next→ "No such file or directory" - Start fresh:
preview_start(returnsreused: false) - Navigate to the same page
- Observe: Browser still renders the OLD version of the component
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.63 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
Root Cause Hypothesis:
The Playwright browser instance used by the Preview tool likely has an aggressive HTTP disk/memory cache that:
- Caches responses by URL (chunk filename hash doesn't change between Turbopack rebuilds)
- Does not respect
Cache-Controlheaders from the dev server - Persists across
preview_stop/preview_startcycles (browser profile is not cleared)
What was tried (all failed):
preview_stop→ delete.next→preview_start(reused: false)- Kill process on port via
kill -9→ delete.next→ restart - Delete
node_modules/.cacheandtsconfig.tsbuildinfo window.location.reload()viapreview_evalwindow.location.replace('/path?_=' + Date.now())(cache-busting URL)caches.keys().then(names => names.forEach(name => caches.delete(name)))viapreview_eval- Navigate to a completely different page and back
Suggested Fix:
- Clear the Playwright browser's HTTP cache when
preview_stopis called - Or: launch Playwright with
--disable-http-cacheflag - Or: use a fresh browser context/profile for each
preview_start
Framework: Next.js 16.1.6 (App Router, Turbopack), port 3444
Frequency: 100% reproducible
Workaround: User's real browser (Chrome) works correctly; only Preview tool is affected
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗