feat(core): Only check for native fetch in browser - #22893
Conversation
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 b9bc3ac. Configure here.
| // falls back to an iframe DOM check to detect a polyfilled/wrapped `fetch` (which we don't want to | ||
| // double-instrument alongside XHR). Outside the browser there is no DOM, and `fetch` may be | ||
| // legitimately wrapped by the host (e.g. Next.js on Bun), so we always patch the global there. | ||
| if (isBrowser() && !supportsNativeFetch()) { |
There was a problem hiding this comment.
Feat PR lacks required tests
Medium Severity
This is a feat PR, but the diff has no integration or E2E test covering the new isBrowser()-gated native-fetch check in instrumentFetch. That violates the testing convention that feat PRs include at least one integration or E2E test. Without that, browser skip vs non-browser always-patch behavior can regress unnoticed.
Triggered by project rule: PR Review Guidelines for Cursor Bot
Reviewed by Cursor Bugbot for commit b9bc3ac. Configure here.
There was a problem hiding this comment.
this is tested in various places already.
There was a problem hiding this comment.
Arguably this is a ref(core), I guess, since it's really not adding any user-facing feature, I guess?
size-limit report 📦
|
| // falls back to an iframe DOM check to detect a polyfilled/wrapped `fetch` (which we don't want to | ||
| // double-instrument alongside XHR). Outside the browser there is no DOM, and `fetch` may be | ||
| // legitimately wrapped by the host (e.g. Next.js on Bun), so we always patch the global there. | ||
| if (isBrowser() && !supportsNativeFetch()) { |
There was a problem hiding this comment.
Arguably this is a ref(core), I guess, since it's really not adding any user-facing feature, I guess?
b9bc3ac to
ae94c1a
Compare


Noticed this here: https://github.com/getsentry/sentry-javascript/pull/22869/changes
The flag for checking native flag is both incorrect I believe and also misleading. Some problems with it:
skipNativeFetchCheck && !supportsNativeFetch()would only check if we define that the check should be skipped?addFetchInstrumentationHandlerlevel, as this can be called multiple times butinstrumentFetchis only called once (whichever is the first caller) so that is also non ideal.Now, instead we simply guard this on
isBrowser()which imho makes more sense and is clearer.