Node.js: Filtering with "beforeSend" not having any effect

We’re attempting to use the beforeSend option to filter a cacophony of bogus errors coming from various scripts (ads, trackers, beacons) injected by our business partners.

However, I am not seeing any effect on our event load; all the matching events end up on the Sentry dashboard.

Unfortunately, while I’ve been able to verify that filtering in general works, I cannot consistently reproduce the errors we want to filter in the filter place. Many of them are AMP errors that I cannot manually trigger.

This is our logic:

import * as Sentry from '@sentry/browser';

  beforeSend: (event, hint) => {
    let ignore = false;

    const err = hint && hint.originalException;
    if (err) {
      ignore = shouldIgnoreException(err.message) || shouldIgnoreException(err.stack);
    if (!ignore) {
      const parsedStack = hint && hint.stack && hint.stack.stack;
      if (parsedStack) {
        ignore = parsedStack.find(s => shouldIgnoreException(s.url));

    if (ignore) {
      return null;
    return event;

const IGNORE = [
  /Bootstrap's JavaScript requires jQuery/,

  // Innocuous browser errors
  /ResizeObserver loop limit exceeded/,
  /ResizeObserver loop completed with undelivered notifications/,
  /Can't execute code from a freed script/,

  // Caused by reCAPTCHA library
  /reCAPTCHA placeholder element must be an element or id/,

  // This one happens frequently, unknown source
  /UnhandledRejection: "Timeout"/

function shouldIgnoreException(s) {
  return s && IGNORE.find(pattern => pattern.test(s));