Repository navigation
fix(bootstrap): Report preload request failures as real errors and metrics - #126592
Merged
Merged
Conversation
The preload-data template rejected failed requests with a [status, statusText] tuple, and its catch block rethrew [error.status, error.statusText]. Arrays have no status property, so every failure became [undefined, undefined], which is reported as "Error: ," and loses both the HTTP status and the original error type. Non-2xx responses now reject with a PreloadRequestError that carries status and statusText, and the catch-and-rethrow is removed so network and JSON parse errors keep their original type. The bootstrap query consumers already catch any rejection and refetch. Fixes JAVASCRIPT-2XH0
The preload-data script runs before the Sentry SDK is initialized, so failures were only reported when the rejection happened to land after SDK init and before a bootstrap query consumed the promise. Track each preload request's outcome, status, and duration on window.__sentry_preload_results so the app can report them as metrics once the SDK loads. Handling the rejection there also stops failed requests from surfacing as unhandled rejections, while the bootstrap queries still receive the rejected promise.
billyvg
marked this pull request as ready for review
October 6, 2026 16:53
cmanallen
approved these changes
Oct 6, 2026
billyvg
added a commit
that referenced
this pull request
Oct 7, 2026
Companion PR to #126592 ## Slop ### Why? The preload requests start before the Sentry SDK is initialized. A failure is only captured if the rejection lands after SDK init and before a bootstrap query reads the promise, so JAVASCRIPT-2XH0 misses fast failures and over-counts pages that never read the data. These failures are expected, and the app already recovers by refetching, so metrics fit better than error events. ### How? After the SDK initializes, the app reports each preload request's outcome from `window.__sentry_preload_results` (recorded by the preload script in #126592) as a `ui.preload-request` distribution, with `request`, `outcome`, `status` and `errorName` attributes. The bootstrap queries now also count whether each request was served by the preload or fell back to the API client: `ui.bootstrap-request` with `preload: used | missing | failed`. The fallback requests themselves go through the API client, so they're already measured as `ui.api-request`. The standalone SPA preload now rejects with a `PreloadRequestError` instead of resolving `null`, and records its outcomes the same way. Works with or without #126592 deployed; without it there are no results to report. Refs JAVASCRIPT-2XH0 <sub>Generated with Claude Code</sub>
This was referenced Oct 7, 2026
billyvg
added a commit
that referenced
this pull request
Oct 9, 2026
#126745) ### Why? Preload request outcomes are now reported as metrics: - #126592 - #126596 Some failures have no HTTP status (`TypeError`, `SyntaxError`), and the metric alone doesn't say why they failed. We want to capture those as exceptions. ### How? Each failed request's result now includes the original error, so the app can capture it once the SDK initializes. Either PR can deploy first: the app ignores the field until the frontend PR lands. Companion frontend PR: - #126746 Refs JAVASCRIPT-2XH0 <sub>Generated with Claude Code</sub>
billyvg
added a commit
that referenced
this pull request
Oct 13, 2026
…6746) ### Why? Preload request outcomes are now reported as metrics: - #126592 - #126596 Some failures have no HTTP status (`TypeError`, `SyntaxError`), and the metric alone doesn't say why they failed. We want to capture those as exceptions. ### How? Failures with an HTTP status stay metrics-only. Failures without one are also sent with `captureException`, tagged with the request name and grouped by error type, since they have no useful stack trace. Either PR can deploy first: until the backend PR lands, only the standalone SPA captures them. Companion backend PR: - #126745 Refs JAVASCRIPT-2XH0 <sub>Generated with Claude Code</sub>
This was referenced Oct 15, 2026
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.
https://sentry.sentry.io/issues/6235565924/?project=11276&referrer=issue-list&statsPeriod=24h has re-emerged since the authv2 changes (fixed by #126593). There were a few problems with what we were doing, e.g. we were throwing an array, and then immediately catch it and expected an error object, but really we caught the re-thrown array. that's why the error message is
,.Also noticed that we have a try/catch around
_preloadData()to suppress these errors too, but it doesn't work because we don'tawait_preloadData(), so the try/catch doesn't do anything.All this to say let's update this to track to Sentry metrics.
The tracking is done in #126596
Slop
Why?
When a preload request fails, the preload-data script rejects with an array instead of an Error. Its
catchthen rethrows[error.status, error.statusText]from that array, so every failure becomes[undefined, undefined]. That gets reported asError: ,, with no HTTP status and no original error type. An earlier fix (#120588) only changed the standalone SPA copy of this function; server-rendered pages still use this template.The script also runs before the Sentry SDK is initialized. A failure is only captured if it lands after SDK init and before a bootstrap query reads the promise, so the resulting issue volume is a biased sample rather than a real failure rate.
How?
A failed response now rejects with a
PreloadRequestErrorthat keepsstatusandstatusText. Network and JSON parse errors now reject with their original errors, because the catch-and-rethrow is gone.Each request's outcome, status, and duration is recorded on
window.__sentry_preload_resultsfor the app to report as metrics after the SDK initializes. Attaching that handler also stops failed requests from surfacing as unhandled rejections. The bootstrap queries still receive the rejected promise and fall back to fetching through the API client.Nothing reads
window.__sentry_preload_resultsuntil the frontend change lands, so this can deploy first.Fixes JAVASCRIPT-2XH0
Generated with Claude Code