Repository navigation
Show startup, compilation, and HMR in Request Insights - #101304
wbinnssmith wants to merge 2 commits into
Conversation
Failing CI jobsCommit: b76a06c | About building and testing Next.js |
55f1da9 to
8280b02
Compare
4c8d089 to
8019495
Compare
|
Vercel Agent finished reviewing your changes. Vercel Agent found issues that need attention. Issues (2) Review steps (1m 26s)Preparing the workspace 25.3s |
8019495 to
bf4558c
Compare
d8a3f47 to
c704b78
Compare
c704b78 to
16d46d9
Compare
16d46d9 to
6941bfa
Compare
6941bfa to
eed571e
Compare
eed571e to
5afd649
Compare
e8ea822 to
5b82111
Compare
There was a problem hiding this comment.
Vercel Agent Verified Review reviewed 5b82111 and isn’t approving it: this repository’s review rules call for a person’s review. 2 open findings are listed in its review summary and inline. View the full report
7d9e9cb to
6c955b6
Compare
There was a problem hiding this comment.
Vercel Agent Verified Review reviewed 6c955b6 and isn’t approving it: this repository’s review rules call for a person’s review. 3 open findings are listed in its review summary and inline. View the full report
6c955b6 to
8328933
Compare
f7d9152 to
634363c
Compare
There was a problem hiding this comment.
Vercel Agent Verified Review reviewed 634363c and isn’t approving it: this repository’s review rules call for a person’s review. 5 open findings are listed in its review summary and inline. View the full report
76365f1 to
703f1cf
Compare
There was a problem hiding this comment.
Vercel Agent Verified Review requests changes on d4c7901: 1 confirmed blocker or major issue, listed in its review summary and inline. View the full report
There was a problem hiding this comment.
Vercel Agent Verified Review reviewed 0b04da7 and isn’t approving it: this repository’s review rules call for a person’s review. 1 open finding is listed in its review summary and inline. View the full report
There was a problem hiding this comment.
Vercel Agent Verified Review reviewed 377648a and isn’t approving it: this repository’s review rules call for a person’s review. 1 open finding is listed in its review summary and inline. View the full report
| height="880" | ||
| /> | ||
|
|
||
| Time not covered by a child span belongs to its nearest visible parent. A gap between routing and rendering appears under `route to render`. Compiling the route for the request appears as `compile-path`. |
There was a problem hiding this comment.
Note
Unverified · Minor — Docs point to route to render, but the default trace view hides it
The new guide text says a gap between routing and rendering "appears under route to render". The router records that span with type Router.invokeRender, and DEFAULT_VISIBLE_SPAN_TYPES doesn't include that type. The non-verbose trace view, which is the overlay's default (verbose: false), therefore drops the span, and the gap shows up under no visible parent. Readers following the docs (and the SKILL guidance built on them) won't find the span unless they turn on verbose mode.
Needs your judgment: the review traced this through the code but couldn’t run anything to prove it.
There was a problem hiding this comment.
Vercel Agent Verified Review requests changes on 72c48a0: 1 confirmed blocker or major issue, listed in its review summary and inline. View the full report
| if (!recordRenderHandoff) { | ||
| return await render() | ||
| } | ||
| return await getTracer().trace( |
There was a problem hiding this comment.
Warning
Confirmed · Major — 'route to render' takes the OTel root slot from BaseServer.handleRequest
In dev with experimental.requestInsights on, the router now runs every render inside getTracer().trace(RouterSpan.invokeRender). NextTracerImpl.trace always sets rootSpanIdKey in the context and registers the outermost span as the root, so once an app registers an OTel context manager (for example @vercel/otel in instrumentation.ts), handleRequest is no longer the root. Its finally block then gets undefined from getRootSpanAttributes() and returns early. The handleRequest span is never renamed to 'GET /route', never gets next.route or http.route, and http.route never reaches the host span. The repro nests the two trace() calls the way router-server.ts and base-server.ts do, using the tracer's real code.
Confirmed by running its repro on this commit and on the base: Its repro fails on the head as it says (exit 1); the base fails it differently (exit 1), so what it tests is new in this change.
There was a problem hiding this comment.
Vercel Agent Verified Review requests changes on 6614f4d: 1 confirmed blocker or major issue, listed in its review summary. View the full report
Rebased onto the Request Insights stack as one commit. The router runs each request inside its Request Insights identity, so compile-path spans recorded during route matching attach to the request; drop the history assertions and the opt-in config from the tooling fixture. Co-Authored-By: Claude <[email protected]>
import-request-insight-spans now imports local-span-ids directly, so webpack bundled a second counter into the dev app-page runtimes and re-imported validation spans could reuse IDs within one trace. Externalize it alongside the recorder and span store.
There was a problem hiding this comment.
Vercel Agent Verified Review requests changes on b76a06c: 1 confirmed blocker or major issue, listed in its review summary. View the full report
What?
Record dev startup, compilation, and HMR through the shared local recorder. Compilation is attached to the request that triggered it, so a cold compile shows up in that request's trace instead of as an untraced gap. Activity with no request behind it gets its own Background entry, including client HMR latency.
The router records the handoff to rendering as a
route to renderspan, so time between routing and rendering, often a cold compile, shows under that span instead of as a gap. A request's start time includes spans that start beforeBaseServer.handleRequest, such ascompile-pathand that handoff; request spans still set the end. The router sets the Request Insights opt-in before workers fork, so spans recorded during startup, before any request or render server exists, are kept.Why?
A cold compile, startup, or HMR used to appear as an untraced gap or not at all, so slow first requests looked like application time.
How?
These spans are ordinary Next.js spans. Background entries show all of their spans by default, and
compile-pathis visible by default inside requests. The CLI, filters, and trace viewer list Background entries. Producers opt into Request Insights recording explicitly, independently of application OTel configuration. Webpack isn't instrumented: under--webpack, startup andcompile-pathstill appear, but webpack compiles and client HMR latency aren't recorded.Verification
pnpm testonly packages/next/src/server/lib/trace/ packages/next/src/next-devtools/dev-overlay/ packages/next/src/trace/pnpm --filter=next typesrequest-insights.test.ts: "keeps a cold compile before the request span in request timing" and "keeps the router handoff that ends after the request span"pnpm test-dev-turboandpnpm test-dev-webpackontest/development/app-dir/request-insights-background/andtest/development/app-dir/hmr-trace-timing/. The background HMR case is Turbopack-only (@force-gate turbopack).pnpm test-dev-turbo test/development/app-dir/request-insights/