ref(core)!: Remove supportsNativeFetch export - #23719
Conversation
size-limit report 📦
|
4bf8c35 to
4a25c19
Compare
| */ | ||
| function _wrapFetch(client: Client, options: HttpClientOptions): void { | ||
| if (!supportsNativeFetch()) { | ||
| return; | ||
| } | ||
|
|
||
| addFetchInstrumentationHandler(handlerData => { |
There was a problem hiding this comment.
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.
4a25c19 to
1c482b3
Compare
|
|
||
| export { spanStreamingIntegration } from './integrations/browserSpanStreaming'; | ||
|
|
||
| export { supportsNativeFetch } from './utils/supports'; | ||
| export type { XhrBreadcrumbData, XhrBreadcrumbHint } from './types/breadcrumb'; | ||
| export type { BrowserClientReplayOptions } from './types/browseroptions'; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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'; |
There was a problem hiding this comment.
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.
Triggered by project rule: PR Review Guidelines for Cursor Bot
Reviewed by Cursor Bugbot for commit 1c482b3. Configure here.
1c482b3 to
8d5c407
Compare


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