Repository navigation
Show the component import in sync IO prerender code frames - #102292
Closed
aurorascharff wants to merge 3 commits into
Closed
aurorascharff wants to merge 3 commits into
aurorascharff wants to merge 3 commits into
Conversation
<!-- NEXT_JS_LLM -->
Contributor
Failing test suitesCommit: 495c4f1 | About building and testing Next.js
Expand output● dev indicator - Hide DevTools Button › should visibly record a shortcut and let it toggle visibility immediately after saving
Expand output● next-server-nft › with adapters › should not trace too many files in next-minimal-server.js.nft.json |
<!-- NEXT_JS_LLM -->
<!-- NEXT_JS_LLM -->
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.
Closed by #102471.
When a third-party component reads the clock, calls
Math.random(), or generates a value with a synchronous crypto API during prerendering, the code frame can point to a JSX tag without naming its package. In the example below, theexternal-timedependency exportsBlockingWidgetand reads the clock. The app imports and renders that component. Show the import above the JSX, with the caret on the line the app author can edit.This is an alternative to #102189, using its third-party date reproduction. Stack ordering and ignore-list behavior stay the same.
Before and after
Output from the shared code-frame renderer for the same mapped position in the fixture, with the import hint disabled and enabled:
Before
After
The dev overlay and terminal opt into the hint for sync IO prerender diagnostics (time, random, and crypto). It needs a mapped application frame pointing at an opening JSX component tag. It resolves the local binding, including aliased imports, and shows the declaration in source order in the same numbered excerpt. Only the JSX use has a caret. For a distant import, an ellipsis marks the omitted lines. If the tag resolves to a local binding or relative import, the source cannot be parsed, or the file exceeds the size limit, the original code frame stands on its own. The import identifies the component's source; it does not claim the package owns the innermost clock read.
Verification
new Date(),Date.now(),Math.random(), Web Crypto'scrypto.getRandomValues(), and Node'srandomUUID()fromnode:crypto. For each route it checks the failing expression and the corresponding app import in the dev overlay and debug build output. All five routes share one dev server and one debug build per test configuration.