Skip to content

Commit a852e32

Browse files
authored
Improve Sentry Error Filtering (#772)
* fix: miniflare from errors from users should be ignored by Sentry
1 parent 85b0c31 commit a852e32

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

.changeset/breezy-steaks-visit.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"wrangler": patch
3+
---
4+
5+
fix: We want to prevent any user created code from sending Events to Sentry,
6+
which can be captured by `uncaughtExceptionMonitor` listener.
7+
Miniflare code can run user code on the same process as Wrangler,
8+
so we want to return `null` if `@miniflare` is present in the Event frames.

packages/wrangler/src/reporting.ts

+15
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,21 @@ export function initReporting() {
3030
// from their worker during development
3131
return null;
3232
},
33+
/**
34+
* We want to prevent any user created code from sending Events to Sentry,
35+
* which can be captured by "uncaughtExceptionMonitor" listener.
36+
* Miniflare code runs on the same process as Wrangler, so we want to return `null`
37+
* if "@miniflare" is present in the Event frames.
38+
*/
39+
beforeSend: (event) => {
40+
return !event.exception?.values?.some((value) =>
41+
value.stacktrace?.frames?.some((frame) =>
42+
frame.module?.includes("@miniflare")
43+
)
44+
)
45+
? event
46+
: null;
47+
},
3348
dsn: "https://[email protected]/6190959",
3449
tracesSampleRate: 1.0,
3550
integrations: [

0 commit comments

Comments
 (0)