Skip to content

ref(core)!: Remove supportsNativeFetch export - #23719

Open
mydea wants to merge 2 commits into
developfrom
fn/remove-supports-native-fetch
Open

ref(core)!: Remove supportsNativeFetch export#23719
mydea wants to merge 2 commits into
developfrom
fn/remove-supports-native-fetch

Conversation

@mydea

@mydea mydea commented Aug 28, 2026

Copy link
Copy Markdown
Member

Removes this export from core. It was only used by HttpClient integration to guard adding the fetch instrumentation, which should not be necessary (we do not do this for other places).

@github-actions

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 28.56 kB - -
@sentry/browser - with treeshaking flags 26.92 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 26.82 kB - -
@sentry/browser (incl. Tracing) 48.63 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.64 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.55 kB - -
@sentry/browser (incl. Tracing, Replay) 88.09 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.52 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 92.79 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 105.73 kB - -
@sentry/browser (incl. Feedback) 46.05 kB - -
@sentry/browser (incl. sendFeedback) 33.62 kB - -
@sentry/browser (incl. FeedbackAsync) 38.73 kB - -
@sentry/browser (incl. Metrics) 29.51 kB - -
@sentry/browser (incl. Logs) 29.8 kB - -
@sentry/browser (incl. Metrics & Logs) 30.43 kB - -
@sentry/react 30.3 kB - -
@sentry/react (incl. Tracing) 50.83 kB - -
@sentry/vue 35.69 kB - -
@sentry/vue (incl. Tracing) 50.86 kB - -
@sentry/svelte 28.59 kB - -
CDN Bundle 30.35 kB - -
CDN Bundle (incl. Tracing) 49.23 kB - -
CDN Bundle (incl. Logs, Metrics) 32.58 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 51.12 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 73.17 kB - -
CDN Bundle (incl. Tracing, Replay) 86.72 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.6 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 92.62 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.5 kB - -
CDN Bundle - uncompressed 89.95 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.82 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 96.24 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 152.51 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 225.41 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 266.32 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 272 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 280.02 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 285.69 kB - -
@sentry/nextjs (client) 53.41 kB - -
@sentry/sveltekit (client) 49.07 kB - -
@sentry/core/server 65.15 kB - -
@sentry/core/browser 51.79 kB -0.03% -12 B 🔽
@sentry/node 122.74 kB +0.02% +17 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 85.23 kB - -
@sentry/node - without tracing 87.74 kB +0.03% +25 B 🔺
@sentry/node - without channel injection 102.4 kB +0.02% +16 B 🔺
@sentry/aws-serverless 95.9 kB +0.03% +24 B 🔺
@sentry/cloudflare (withSentry) - minified 199.69 kB - -
@sentry/cloudflare (withSentry) 496.19 kB - -

View base workflow run

@mydea
mydea force-pushed the fn/remove-supports-native-fetch branch from 4bf8c35 to 4a25c19 Compare August 28, 2026 08:50
@mydea
mydea marked this pull request as ready for review August 28, 2026 09:09
@mydea
mydea requested a review from a team as a code owner August 28, 2026 09:09
@mydea
mydea requested review from logaretm and msonnb and removed request for a team August 28, 2026 09:09
Comment on lines 281 to 283
*/
function _wrapFetch(client: Client, options: HttpClientOptions): void {
if (!supportsNativeFetch()) {
return;
}

addFetchInstrumentationHandler(handlerData => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Removing the supportsNativeFetch() guard causes a handler to be registered even when fetch instrumentation is not supported, resulting in a minor memory leak.
Severity: LOW

Suggested Fix

Restore the if (!supportsNativeFetch()) { return; } guard around the call to addFetchInstrumentationHandler in the _wrapFetch function to prevent registering a handler that will never be used.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: packages/browser/src/integrations/httpclient.ts#L281-L283

Potential issue: By removing the `supportsNativeFetch()` check, the
`addFetchInstrumentationHandler` function is now called even in environments where
native fetch is not supported. This registers a handler callback in a global array.
However, the actual instrumentation of the `fetch` API is subsequently aborted due to an
internal check. This results in a registered handler that is never called, causing a
minor memory leak for the lifetime of the application in environments like older
browsers or those with polyfilled fetch.

Did we get this right? 👍 / 👎 to inform future reviews.

@mydea
mydea force-pushed the fn/remove-supports-native-fetch branch from 4a25c19 to 1c482b3 Compare August 28, 2026 09:34
Comment on lines 15 to 19

export { spanStreamingIntegration } from './integrations/browserSpanStreaming';

export { supportsNativeFetch } from './utils/supports';
export type { XhrBreadcrumbData, XhrBreadcrumbHint } from './types/breadcrumb';
export type { BrowserClientReplayOptions } from './types/browseroptions';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The removal of supportsNativeFetch from public exports in @sentry/core/browser will break a test in httpclient.test.ts that spies on this function.
Severity: HIGH

Suggested Fix

Update the test in packages/browser/test/integrations/httpclient.test.ts. Either import supportsNativeFetch directly from its source file (../utils/supports) for mocking, or refactor the test to no longer depend on this removed public export.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: packages/core/src/browser-exports.ts#L15-L19

Potential issue: The function `supportsNativeFetch` has been removed from the public
exports in `packages/core/src/browser-exports.ts`. However, the test file
`packages/browser/test/integrations/httpclient.test.ts` still imports it from
`@sentry/core/browser` and attempts to create a spy on it using `vi.spyOn(SentryCore,
'supportsNativeFetch')`. After this change, `SentryCore.supportsNativeFetch` will be
`undefined`, causing the spy to fail and breaking the test suite. While internal usage
is unaffected, the test represents a consumer of the public API that will now fail.

Also affects:

  • packages/browser/test/integrations/httpclient.test.ts

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1c482b3. Configure here.


export { spanStreamingIntegration } from './integrations/browserSpanStreaming';

export { supportsNativeFetch } from './utils/supports';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Public API removed without deprecation

Medium Severity

This was flagged because the review rules call out removal of publicly exported functions without a deprecation notice. supportsNativeFetch was a public export from @sentry/core and @sentry/core/browser with no @hidden or @deprecated tag. Similar helpers such as supportsFetch stay exported as deprecated, and the v11 migration guide does not list this removal.

Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit 1c482b3. Configure here.

Base automatically changed from fn/remove-more-core-exports to develop August 28, 2026 09:53
@mydea
mydea force-pushed the fn/remove-supports-native-fetch branch from 1c482b3 to 8d5c407 Compare August 28, 2026 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant