next.js
e8b31a2c - Don't block the dev overlay on the npm registry version check (#100628)

Commit
21 days ago
Don't block the dev overlay on the npm registry version check (#100628) ## Summary A slow or unreachable package registry can delay the dev server's version-staleness lookup. Turbopack currently awaits that lookup before sending the HMR `sync` message. Webpack and Rspack await it during hot-reloader startup. A late `sync` can also replay an error snapshot captured before the wait and clear newer build errors. On the original base, delaying `sync` kept the entire dev overlay invisible, including build-error redboxes. #100629 independently fixed that client-side rendering dependency and is now merged. This PR removes the server-side delay and stale-error replay. The version check is now non-blocking: - **Immediate sync.** Until the lookup resolves, `sync` includes the installed version with `unknown` staleness. Later connections get the resolved value. - **Version-only update.** When metadata resolves, connected clients receive a `versionInfo` HMR message. It updates only version metadata, rather than replaying errors or hash state through a second `sync`. - **Current errors.** Turbopack collects issues when `sync` is built, after the remaining asynchronous work, not before it. - **Non-blocking Webpack/Rspack startup.** The middleware starts with pending metadata, then caches and publishes the result. - **Explicit rejection handling.** Both background broadcast chains log rejections, including exceptions in their success callbacks. Webpack also attaches a handler when creating the lookup promise so it cannot reject unhandled before middleware subscribes; failure retains pending metadata. Both metadata helpers use the compiled `process.env.__NEXT_VERSION`. The lookup remains lazy in Turbopack. Canary's configured-registry and response-validation behavior is preserved, and no fetch timeout is added. The regression fixture holds the dev server's registry request until the test releases it. For app and pages routers, it checks the redbox and pending version while the lookup is blocked, then verifies that version staleness updates without clearing the build error. The existing runtime/render/build staleness tests now mock registry dist-tags instead of rewriting the installed package. Both fixture overrides support custom registry hosts and path prefixes without depending on a live registry response. ## Verification On the rebased branch: - `test/development/app-dir/dev-overlay-pending-version-info` and `test/development/acceptance-app/version-staleness.test.ts`: 5/5 passed in Turbopack dev and 5/5 in webpack dev. - Full `pnpm build-all`, including source-matched native bindings. - Framework types, root TypeScript, prettier and eslint. - Supporting local rejection checks: the original middleware produced unhandled rejections for rejected lookups and throwing publishes; the handlers log these instead. Additional isolated checks cover the Turbopack broadcast and Webpack's early fallback. The initial implementation was also verified with `ReactRefreshLogBox-builtins`, `rsc-build-errors-react-apis-1`, `dev-indicator`, and `hide-button` in both bundlers. The pending-version-info regression and `rsc-build-errors-react-apis-1` also passed with cache components enabled in Turbopack dev. The original pre-#100629 baseline failed the regression (Turbopack: missing redbox; webpack: navigation timeout while startup waited for the lookup). Rspack was not run locally; it shares the Webpack hot-reloader path. Rejection smoke checks are supporting local checks, not a committed integration test. <!-- NEXT_JS_LLM --> <!-- fleet 64c837ee-843c-4c4b-b256-57dd903babf5 --> --------- 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>
Author
Parents
Loading