Repository navigation
Description
Environment
@telemetry-tracker/next1.3.3@telemetry-tracker/core1.5.3- Next.js 16.4.5 (Turbopack prod:
next build && next start), React 19.3.1 - Setup follows the current
/docs/nextjsguide (TelemetryProviderin the root layout)
Symptom
Client render crashes that show Next.js 16.2+'s "This page couldn't load / Reload to try again, or go back." screen are not reported to Telemetry Tracker when using the documented provider setup.
- A crash during the first page load sends nothing (SDK never finishes init).
- Even
app/global-error.tsxthat callstrackErroris lost when the provider was the only init path.
Cause
TelemetryProvider's useLayoutEffect cleanup calls shutdown() (core clears config). When a render crash replaces the page tree with the default/custom global error UI, the provider unmounts first. Next then reports the error (reportGlobalError → window.onerror), but getConfigOrNull() is already null, so the error is dropped.
Hydration / first-paint crashes are worse: the provider's layout effect never committed, so init never ran at all.
Next internals note: errors caught by the built-in default global error are treated as uncaught (reportGlobalError → window error event). Errors caught by an app's own error.tsx / global-error.tsx go to onCaughtError → console.error only (never window.onerror), so they still need an explicit trackError in that boundary.
Workaround (verified)
Initialising the SDK in instrumentation-client.ts (Next 15.3+), without relying on TelemetryProvider for init, caught all 5 test crash paths in local verification. Use useTrackPage (or equivalent) for $screen as needed.
Repro and results
Local verification on 2026-11-09 (Europe/Ljubljana) against a mock ingest and headless Chrome.
Crash routes exercised:
| Route | What throws |
|---|---|
/click |
Client render throws after a button click |
/effect |
Client render throws ~500 ms after mount |
/render |
Client render throws during hydration |
/handler |
Error thrown in onClick (not render) |
/promise |
Async onClick rejects |
Results by setup:
| Variant | Setup | /click |
/effect |
/render |
/handler |
/promise |
|---|---|---|---|---|---|---|
| A | Documented /docs/nextjs: TelemetryProvider in root layout |
NOT reported | NOT reported | NOT reported (no init) | reported | reported |
| B | init() at module scope in a client module, no provider |
reported | reported | reported | – | – |
| C | Provider + TelemetryErrorBoundary around children |
reported (fallback) | reported | NOT reported | – | – |
| D | init() in instrumentation-client.ts, no provider |
reported | reported | reported | reported | reported |
| E | D + global-error.tsx with trackError; segment error.tsx without |
reported | NOT reported (segment swallows) | reported | – | – |
| F | A + global-error.tsx with trackError |
NOT reported | – | NOT reported | – | – |
Proposed fix
- SDK: Do not shut the SDK down on
TelemetryProviderunmount (target@telemetry-tracker/next1.3.4), with a regression test that a render crash after provider unmount still reaches ingest. - Docs: Recommend
instrumentation-client.tsinit on/docs/nextjs,/error-tracking/nextjs, and/monitoring/nextjs(in addition to or instead of provider-only init).
Blocker note
The planned SEO page /error-tracking/nextjs/this-page-couldnt-load is blocked until this is fixed (or until docs + page exclusively teach the working instrumentation-client.ts path and the provider bug is clearly called out).
Acceptance
- With the documented Next.js setup,
/click,/effect, and/rendercrashes that show "This page couldn't load" are ingested. - Regression test covers provider unmount vs. late
window.onerror/reportGlobalError. - Docs stop implying provider-only init is enough for render crashes on Next 16.2+.
Activity
unjica commentedon Nov 13, 2026
SEO Optimization (2026-11-13): taking only the /error-tracking/nextjs docs part in #960. Re-verified today on Next.js 16.4.6 + @telemetry-tracker/next 1.3.3 (prod build, headless Chrome, mock ingest): provider-only init drops global-error and hydration crashes (even with trackError in global-error.tsx); init() in instrumentation-client.ts + useTrackPage reports all paths and $screen events. SDK fix and /docs/nextjs + /monitoring/nextjs updates remain on this issue.
unjica commentedon Nov 16, 2026
Cross-link only: the SEO page
/error-tracking/nextjs/this-page-couldnt-loadis now tracked as #969. It stays blocked on this issue. SEO & Content Research is re-scoping the 2026-11-09 brief (overlap with the v1.22.36/error-tracking/nextjsupdate), so #969 must not be built from the current brief.