Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
JPeer264 wants to merge9 commits intodevelop
base:develop
Choose a base branch
Loading
fromjp/enhance-fetch-error-message

Conversation

@JPeer264
Copy link
Member

@JPeer264JPeer264 commentedDec 10, 2025
edited
Loading

(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, sincefetch has no integration this has to be added as ainit option).always is the default and acts the same as it is now, so it is acting as feature:

enhanceFetchErrorMessages:'always'|'report-only'|false`

To give the user full control of how the errors are done there are 3 settings:

alwaysreport-onlyfalse
manipulate the error message directly
send only the changed message to Sentry

Special attention to reviewers

When havingreport-only the 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 yet

Alternative

In case the size increase is too much, we can also have a boolean that disables that (which is on by default)

@linear
Copy link

linearbot commentedDec 10, 2025

@github-actions
Copy link
Contributor

github-actionsbot commentedDec 10, 2025
edited
Loading

size-limit report 📦

PathSize% ChangeChange
@sentry/browser24.91 kB+0.35%+85 B 🔺
@sentry/browser - with treeshaking flags23.42 kB+0.45%+104 B 🔺
@sentry/browser (incl. Tracing)41.72 kB+0.31%+127 B 🔺
@sentry/browser (incl. Tracing, Profiling)46.31 kB+0.25%+112 B 🔺
@sentry/browser (incl. Tracing, Replay)80.31 kB+0.16%+127 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags70 kB+0.13%+88 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas)84.99 kB+0.15%+124 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback)97.21 kB+0.12%+110 B 🔺
@sentry/browser (incl. Feedback)41.63 kB+0.24%+97 B 🔺
@sentry/browser (incl. sendFeedback)29.59 kB+0.29%+85 B 🔺
@sentry/browser (incl. FeedbackAsync)34.61 kB+0.31%+105 B 🔺
@sentry/react26.64 kB+0.38%+99 B 🔺
@sentry/react (incl. Tracing)43.89 kB+0.22%+95 B 🔺
@sentry/vue29.38 kB+0.34%+98 B 🔺
@sentry/vue (incl. Tracing)43.51 kB+0.24%+101 B 🔺
@sentry/svelte24.93 kB+0.38%+92 B 🔺
CDN Bundle27.34 kB+0.32%+87 B 🔺
CDN Bundle (incl. Tracing)42.34 kB+0.25%+103 B 🔺
CDN Bundle (incl. Tracing, Replay)79.05 kB+0.13%+101 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback)84.5 kB+0.1%+81 B 🔺
CDN Bundle - uncompressed80.37 kB+0.39%+310 B 🔺
CDN Bundle (incl. Tracing) - uncompressed125.72 kB+0.25%+310 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed242.25 kB+0.13%+310 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed255.02 kB+0.13%+310 B 🔺
@sentry/nextjs (client)46.11 kB+0.22%+101 B 🔺
@sentry/sveltekit (client)42.08 kB+0.27%+113 B 🔺
@sentry/node-core51.66 kB+0.09%+45 B 🔺
@sentry/node161.55 kB+0.04%+51 B 🔺
@sentry/node - without tracing93.09 kB+0.05%+42 B 🔺
@sentry/aws-serverless108.6 kB+0.04%+43 B 🔺

View base workflow run

@github-actions
Copy link
Contributor

github-actionsbot commentedDec 10, 2025
edited
Loading

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.

ScenarioRequests/s% of BaselinePrev. Requests/sChange %
GET Baseline9,386-8,907+5%
GET With Sentry1,77419%1,760+1%
GET With Sentry (error only)6,27767%6,292-0%
POST Baseline1,224-1,230-0%
POST With Sentry60049%590+2%
POST With Sentry (error only)1,06887%1,081-1%
MYSQL Baseline3,393-3,375+1%
MYSQL With Sentry45113%459-2%
MYSQL With Sentry (error only)2,75281%2,718+1%

View base workflow run

Copy link
Member

@Lms24Lms24 left a 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!

@Lms24
Copy link
Member

(I was thinking for a moment if it makes sense for us to only add the option to theglobalHandlersIntegration but that's very hard to discover for users and we have to pay the size hit either way. So I'm fine with adding the top-level option)

JPeer264and others added8 commitsDecember 18, 2025 10:56
…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>
@JPeer264JPeer264force-pushed thejp/enhance-fetch-error-message branch from0350acc to308c1f2CompareDecember 18, 2025 09:57
Comment on lines +118 to +119
constenhanceOption=client?.getOptions().enhanceFetchErrorMessages??'always';
constshouldEnhance=enhanceOption!==false;
Copy link

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

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@Lms24Lms24Lms24 approved these changes

@logaretmlogaretmAwaiting requested review from logaretm

+1 more reviewer

@sentrysentry[bot]sentry[bot] left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Appending hostname to fetch error messages breaks is-network-error and p-retry packages

3 participants

@JPeer264@Lms24

[8]ページ先頭

©2009-2025 Movatter.jp