beforeSend filter not filtering out events

We have a beforeSend filter set up with Sentry that looks like this:

    beforeSend: (event: Event, hint?: EventHint) => {
      if (hint) {
        // Filter out some errors we don't care about
        const error = hint.originalException
        let errorMessage: string | undefined
        if (typeof error === 'string') {
          errorMessage = error
        } else if (error instanceof Error) {
          errorMessage = error.message

        switch (errorMessage) {
          case 'timeout':
          case 'Invalid to header':
          case 'Invalid To header':
          case 'Mailbox not enabled':
          case 'Auth window was closed by user':
          case 'The request timed out.':
          case 'Network request failed':
          case 'Mail service not enabled':
          case 'apiClient is null - call configure first':
          case 'Backend Error':
            return null

      return event

This filter doesn’t seem to be filtering out some events I would expect it to, though. We’re still getting reports of “Backend Error” events when those should be filtered out. Here’s an example:

Here’s a direct link to the JSON for that event, if that’s helpful:

I can see by running window.__SENTRY__.hub._stack[0].client._options.beforeSend.toString() in the console window for our prod site in Chrome that ‘Backend Error’ is included in the list of events we should be filtering out. I’m seeing this with @sentry/browser 5.0.6.

How can I make the beforeSend function filter out this event? Do I need to check for “UnhandledRejection: Backend Error” too?

Code seems fine but generally I would do a regex match instead of string compare in a switch/case. Since browsers are different it’s not guaranteed that everything is the same all the time.