What version of Effect is running?
[email protected]
What steps can reproduce the bug?
- Install NextJS v16.0.1
- Set
cacheComponents: true in next.config.ts
- Use Effect.runPromise or Effect.runPromiseExit or a custum runtime.runPromise, etc, in any React Server Component on a page
- Run pnpm dev
- Go to the page
- See the error.
What is the expected behavior?
There should be no error and the build shouldn't fail.
What do you see instead?
Route "/my_page" used Date.now() before accessing either uncached data (e.g. fetch()) or Request data (e.g. cookies(), headers(), connection(), and searchParams). Accessing the current time in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-current-time
Additional information
Responsible file:
node_modules/.pnpm/[email protected]/node_modules/effect/src/internal/fiberId.ts
Responisble function:
/** @internal */
export const unsafeMake = (): FiberId.Runtime => {
const id = MutableRef.get(_fiberCounter)
pipe(_fiberCounter, MutableRef.set(id + 1))
return new Runtime(id, Date.now()) // <- Date.now() most likely causes the issue
}
This only happens if you activate cacheComponents. When cacheComponents are not active, you don't get an error.