{{ message }}
fix: replace Date.now() with performance.now() in memo debug timing#6196
Open
isaackaara wants to merge 1 commit intoTanStack:mainfrom
Open
fix: replace Date.now() with performance.now() in memo debug timing#6196isaackaara wants to merge 1 commit intoTanStack:mainfrom
isaackaara wants to merge 1 commit intoTanStack:mainfrom
Conversation
Next.js warns about Date.now() usage in client components because it can cause hydration mismatches between server and client renders. While the Date.now() calls in memo() are only used for debug timing and guarded behind opts.debug, Next.js statically detects Date.now() usage and shows the warning regardless. Switching to performance.now() resolves the warning and provides more precise timing measurements for debug output. The performance.now() API is available in all modern browsers and Node.js 12+, which aligns with the project's engine requirements. Fixes TanStack#6127
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Next.js warns about
Date.now()usage in client components because it can cause hydration mismatches between server and client renders. While theDate.now()calls inmemo()are only used for debug timing and guarded behindopts.debug, Next.js statically detectsDate.now()usage and shows the warning regardless.Switching to
performance.now()resolves the Next.js warning and also provides more precise sub-millisecond timing measurements for debug output. Theperformance.now()API is available in all modern browsers and Node.js 12+, which aligns with the project's engine requirements.This is a debug-only change with no impact on runtime behavior.
Fixes #6127