Dynamic Client Import Triggers Instant Validation Error With CacheComponents And Turbopack Dev
Next.js 16.4.0-canary.22 with Turbopack and experimental cacheComponents reports a dev validation error when a page uses a dynamic import for a client component. The page renders but the validation worker fails with 'module factory is unavailable'. Static imports or disabling devValidationWorker resolve the issue.
The dev validation worker attempts to statically pre-render the route segment for 'instant' validation. When the page contains a dynamic `import()` of a client component, the worker cannot resolve the module factory for that dynamically imported client reference, likely because the client reference manifest or module map for the dynamically imported chunk is not correctly exposed to the worker. This causes the validation worker to throw, which surfaces as 'Could not validate `instant` because an error prevented the target segment from rendering.' The underlying error indicates the dynamically imported client component's module factory is unavailable in the worker's module graph.
1. Clone https://github.com/nikhilsnayak/nextjs-instant-validation-repro.
2. Run `bun install` and `bun run dev`.
3. Open http://localhost:5001/.
4. Check browser console/server terminal for validation error.
Setting `devValidationWorker: false` disables the separate worker process that performs instant validation of cacheComponents. This prevents the worker from attempting to render the route and encountering the missing module factory for the dynamically imported client component. Production builds are unaffected; this only silences the false positive during development.
Edge Case Audit
This is a temporary workaround, not a permanent fix. Disabling `devValidationWorker` eliminates instant validation for all routes that use `cacheComponents`, which may hide real rendering errors in development. To roll back, remove the `devValidationWorker: false` flag (or set it back to true) after upgrading to a Next.js version that fixes the missing module factory. Alternatively, until an official fix is available, consider replacing the dynamic import with a static import for client components that do not need code splitting.