Skip to content

Commit

Permalink
Improve Sentry Error Filtering (#772)
Browse files Browse the repository at this point in the history
* fix: miniflare from errors from users should be ignored by Sentry
  • Loading branch information
JacobMGEvans committed Apr 12, 2022
1 parent 85b0c31 commit a852e32
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .changeset/breezy-steaks-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"wrangler": patch
---

fix: We want to prevent any user created code from sending Events to Sentry,
which can be captured by `uncaughtExceptionMonitor` listener.
Miniflare code can run user code on the same process as Wrangler,
so we want to return `null` if `@miniflare` is present in the Event frames.
15 changes: 15 additions & 0 deletions packages/wrangler/src/reporting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@ export function initReporting() {
// from their worker during development
return null;
},
/**
* We want to prevent any user created code from sending Events to Sentry,
* which can be captured by "uncaughtExceptionMonitor" listener.
* Miniflare code runs on the same process as Wrangler, so we want to return `null`
* if "@miniflare" is present in the Event frames.
*/
beforeSend: (event) => {
return !event.exception?.values?.some((value) =>
value.stacktrace?.frames?.some((frame) =>
frame.module?.includes("@miniflare")
)
)
? event
: null;
},
dsn: "https://5089b76bf8a64a9c949bf5c2b5e8003c@o51786.ingest.sentry.io/6190959",
tracesSampleRate: 1.0,
integrations: [
Expand Down

0 comments on commit a852e32

Please sign in to comment.