Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork1.7k
feat(core): Add option to enhance the fetch error message#18466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:develop
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
github-actionsbot commentedDec 10, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
size-limit report 📦
|
github-actionsbot commentedDec 10, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
node-overhead report 🧳Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.
|
Lms24 left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Sounds reasonable to me! Let's make sure to document the new option, thanks!
dev-packages/browser-integration-tests/suites/errors/fetch-enhance-messages-off/test.ts OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
dev-packages/browser-integration-tests/suites/errors/fetch-enhance-messages-off/test.ts OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
dev-packages/browser-integration-tests/suites/errors/fetch-enhance-messages-off/test.ts OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
dev-packages/browser-integration-tests/suites/errors/fetch-enhance-messages-report-only/test.ts OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
dev-packages/browser-integration-tests/suites/errors/fetch-enhance-messages-report-only/test.ts OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
dev-packages/browser-integration-tests/suites/errors/fetch-enhance-messages-report-only/test.ts OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Lms24 commentedDec 17, 2025
(I was thinking for a moment if it makes sense for us to only add the option to the |
…ance-messages-off/test.tsCo-authored-by: Lukas Stracke <lukas.stracke@sentry.io>
…ance-messages-off/test.tsCo-authored-by: Lukas Stracke <lukas.stracke@sentry.io>
…ance-messages-report-only/test.tsCo-authored-by: Lukas Stracke <lukas.stracke@sentry.io>
…ance-messages-off/test.tsCo-authored-by: Lukas Stracke <lukas.stracke@sentry.io>
…ance-messages-report-only/test.tsCo-authored-by: Lukas Stracke <lukas.stracke@sentry.io>
…ance-messages-report-only/test.tsCo-authored-by: Lukas Stracke <lukas.stracke@sentry.io>
0350acc to308c1f2Compare| constenhanceOption=client?.getOptions().enhanceFetchErrorMessages??'always'; | ||
| constshouldEnhance=enhanceOption!==false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Bug:client?.getOptions() can beundefined, but the subsequent access to.enhanceFetchErrorMessages is not optional, causing aTypeError if no client is available.
Severity: CRITICAL | Confidence: High
🔍Detailed Analysis
Inpackages/core/src/instrument/fetch.ts, the code attempts to accessenhanceFetchErrorMessages on the result ofclient?.getOptions(). ThegetClient() function can returnundefined, in which caseclient?.getOptions() also returnsundefined. The subsequent property access is not using optional chaining (?.), leading to an attempt to read a property onundefined. This will throw aTypeError, causing the fetch instrumentation to crash whenever the SDK client is not available (e.g., before initialization or when disabled).
💡Suggested Fix
Use optional chaining for the entire property access path to safely handle cases where the client or options are undefined. Change the line toconst enhanceOption = client?.getOptions()?.enhanceFetchErrorMessages ?? 'always'; to prevent the TypeError.
🤖Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AIagent.Verify if this is a real issue. If it is, propose a fix; if not, explain why it's notvalid.Location: packages/core/src/instrument/fetch.ts#L118-L119Potential issue: In `packages/core/src/instrument/fetch.ts`, the code attempts to access`enhanceFetchErrorMessages` on the result of `client?.getOptions()`. The `getClient()`function can return `undefined`, in which case `client?.getOptions()` also returns`undefined`. The subsequent property access is not using optional chaining (`?.`),leading to an attempt to read a property on `undefined`. This will throw a `TypeError`,causing the fetch instrumentation to crash whenever the SDK client is not available(e.g., before initialization or when disabled).Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID:7704468
Uh oh!
There was an error while loading.Please reload this page.
(closes#18449)
(closesJS-1281)
Problem
As of now, the user has no chance to disallow the manipulation of fetch errors, as we overwrite the error. This can cause problems as seen in#18449.
Solution
This adds a new option for the SDK (please be very critical about that new option here, since
fetchhas no integration this has to be added as ainitoption).alwaysis the default and acts the same as it is now, so it is acting as feature:To give the user full control of how the errors are done there are 3 settings:
Special attention to reviewers
When having
report-onlythe generated logs locally differ from the ones in Sentry. I am not quite sure if that would cause any problems. This is the only question which I don't have the answer to yetAlternative
In case the size increase is too much, we can also have a boolean that disables that (which is on by default)