Create cache directory before persisting Chrome DevTools workspace UUID (#100802)
### What? When the dev server answers the Chrome DevTools workspace request (`/.well-known/appspecific/com.chrome.devtools.json`) and there's no persisted UUID yet, it now creates `<distDir>/cache` before writing `chrome-devtools-workspace-uuid`. ### Why? The UUID was written with a bare `writeFile`. If the cache directory didn't exist at the time of the first DevTools request (e.g. it was removed while `next dev` was running), the write failed with `ENOENT`. That logged the "needs to be reconnected after the next page reload" warning and kept the UUID in memory only, so the next server process generated a new UUID and the DevTools workspace had to be reconnected. On a normal startup the directory usually already exists because other startup writers create it, which is why this rarely shows up. ### How? - The directory is created recursively inside the existing `try/catch`. If creating the directory or writing the file fails (e.g. an unwritable path), the endpoint still responds with an in-memory UUID and logs the existing warning. **Test:** a dev-only e2e test (`// @force-gate dev`) in `test/e2e/chrome-devtools-workspace/`, using a dedicated fixture: - It waits for the asynchronous startup writes into the cache directory (`.rscinfo`, plus `next-devtools-config.json` with webpack), then removes the directory. - It then checks the endpoint returns a UUID, that the same UUID is on disk, and that no persistence warning is logged. After restarting the server, the same UUID must be returned. - The fixture disables the Turbopack filesystem cache so it can't recreate the directory mid-test. ### Verification - The new test fails without the fix and passes with it under `test-dev-turbo` and `test-dev-webpack`. - The existing `test/e2e/chrome-devtools-workspace/` suites still pass in dev (Turbopack and webpack) and in `test-start-turbo`. - Manual check: when the cache path is a regular file, so the directory can't be created, the endpoint still returns a UUID and logs the warning instead of crashing. <!-- NEXT_JS_LLM --> <!-- fleet f94f85f4-f8af-450a-a1ca-28243552f5f0 --> Co-authored-by:vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com>
Showing
Please
register
or
sign in
to comment