Sentry JS SDK ignoreErrors: anchored /^Failed to fetch$/ never matches because the SDK appends ' (host)' to fetch errors
Adding Sentry browser ignoreErrors entries for bare network failures in a SvelteKit app on @sentry/sveltekit (@sentry/core 10.70). Wanted to drop the generic browser messages 'Failed to fetch' (Chrome), 'Load failed' (Safari) and 'NetworkError when attempting to fetch resource.' (Firefox) without also dropping 'Failed to fetch dynamically imported module: ...' (stale-chunk errors we handle in beforeSend), so the patterns were anchored: /^Failed to fetch$/, /^Load failed$/, /^NetworkError when attempting to fetch resource.$/. They looked right against MDN's documented messages and most published ignoreErrors snippets, but the issues kept matching nothing: the stored exception values in Sentry read e.g. 'TypeError: Failed to fetch (api.example.com)', 'Load failed (api.example.com)', 'NetworkError when attempting to fetch resource. (api.example.com)'.
Recent Sentry JS SDKs (v9.x+/v10, the fetch instrumentation's enhanced error messages) rewrite native fetch TypeErrors to append the request hostname in parentheses: Failed to fetch (api.example.com). ignoreErrors is tested against the exception value and ${type}: ${value}, and the value is the rewritten one, so a fully anchored pattern on the bare browser message never matches. Plain-string entries ('Failed to fetch') are substring matches and do match, but they also swallow Failed to fetch dynamically imported module.
Fix: keep the anchors and allow the optional host suffix:
ignoreErrors: [
/^Failed to fetch( \([^)]*\))?$/,
/^Load failed( \([^)]*\))?$/,
/^NetworkError when attempting to fetch resource\.( \([^)]*\))?$/
]Verify against the real SDK instead of eyeballing regexes:
import { eventFiltersIntegration } from '@sentry/core';
const integ = eventFiltersIntegration({ ignoreErrors: patterns });
const client = { getOptions: () => ({}) };
const ev = { exception: { values: [{ type: 'TypeError', value: 'Failed to fetch (api.example.com)' }] } };
console.log(integ.processEvent(ev, {}, client) === null); // true = droppedWith @sentry/core 10.70 these drop all three host-suffixed variants plus the bare Failed to fetch, and keep Failed to fetch dynamically imported module: https://.../x.js and app errors like Failed to fetch posts: 500. Check the exact stored text first with GET /api/0/organizations/{org}/issues/{id}/ → .metadata.value.