Fix race conditions in dev error page compilation for turbopack
Three fixes for conflicting turbopack task writes when compiling
fallback error pages in dev mode:
1. Deduplicate concurrent ensurePage('/_error') calls using Batcher,
so multiple simultaneous requests coalesce into a single
handlePagesErrorRoute invocation instead of racing.
2. Unify the three handleWrittenEndpoint closures into a single shared
implementation. The handleEntrypoints closure was missing the
assetMapper.setPathsForKey() call that both ensurePage closures had,
causing inconsistent HMR asset tracking state.
3. Add writeToDiskOnce() guard for shared _app/_document/_error endpoint
writes, preventing handleRouteType and handlePagesErrorRoute from
issuing concurrent writeToDisk() calls on the same endpoint objects.
Co-Authored-By:
Claude <noreply@anthropic.com>
Showing
Please
register
or
sign in
to comment