question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

c is not a function when defining custom beforeSend function

See original GitHub issue

Hi, I’m currently trying to customize sentry to prevent the report of several messages that are very noisy in my dashboard. First I tried writing all the errors I want to disable to be tracked inside the ignoreErrors section of config, but it did nothing, after that I tried to make a custom beforeSend function inside the sentry.config attribute, but when building the app it throwed me the same error reported here although I have the latests version. Finally i ended up writing my custom beforeSend function inside the publicRuntimeConfig as one of the comments in this repo issues section said, but now i’m getting this error:

image

The build finishes well, but this error appears each 5 seconds in my sentry console. How to solve it?

Version

@nuxtjs/sentry: 5.1.3 nuxt: 2.15.4

Sentry configuration

sentry: {
    dsn: credentials.SentryConf.dsn,
    lazy: true,
    disabled: !isProd,
    disableServerSide: true,
    tracing: true,
    clientIntegrations: {
      ExtraErrorData
    },
    ignoreErrors: [
      'unhandledRejection',
      'UnhandledRejection',
      'unhandledPromiseRejection',
      'ReportingObserver',
      'Cannot set headers after they are sent to the client',
      'ResizeObserver loop limit exceeded'
    ]
  },
  publicRuntimeConfig: {
    sentry: { // It is necessary to set this config here, because in the common sentry settings it thrown the following error: https://github.com/nuxt-community/sentry-module/issues/266, tested with version 5.1.3
      config: {
        beforeSend(event, hint){
          if (hint.originalException.stack) {
            // eslint-disable-next-line dot-notation
            const errorStack = JSON.stringify(hint.originalException.stack)
  
            const errorsToIgnore = [
              'unhandledRejection',
              'UnhandledRejection',
              'unhandledPromiseRejection',
              'ReportingObserver',
              'Cannot set headers after they are sent to the client',
              'ResizeObserver loop limit exceeded',
              'postMessage',
              'createError',
              'Non-Error promise rejection captured with keys: details, error',
              'Request failed with status code 403',
              'Network Error',
              'disconnected'
            ]
  
            const shouldIgnoreError = errorsToIgnore.some(elem => errorStack.toLowerCase().includes(elem.toLowerCase()))
  
            return shouldIgnoreError ? null : event;
  
         }
  
          return event;
        }
      }
    }
  },

Steps to reproduce

Just create a nuxt project with the versions and settings mentioned above.

What is Expected?

The expected behavior is that sentry ignored the array of errors I’ve manually set and not show the c is not a function error,

What is actually happening?

I’m receiving hundreds of times the c is not a function error.

I’m new to Sentry, so if I’m doing it bad, please explain me how to avoid Sentry reports of the array of error I have set. Thanks a lot.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
rchlcommented, Sep 18, 2021
1. How do I enable that integration if I don't provide the imported class?

Just do ExtraErrorData: {},. As long as it’s one of the official integrations this will enable it.

0reactions
rchlcommented, Sep 24, 2021

Closing then. I think it would work better with later versions of Nuxt. There were some fixes around serializing functions in the config.

In Nuxt 2.15.8 all cases worked correctly when I’ve tested.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ajax beforesend method is not working in some cases
I am not sure why some Ajax calls are not getting intercepted while others are. Below is the code snippet : $(document).ready(function() {...
Read more >
Ajax (remote data) - The jQuery replacement for select boxes
ajax function that executes AJAX requests. There are a few custom options that Select2 will intercept, allowing you to customize the request as...
Read more >
If a custom beforeSubmit() or beforeSend() function ... - Drupal
If a custom beforeSubmit() or beforeSend() function on a Drupal.ajax object returns false, 'ajaxing' gets stuck as true. Needs work.
Read more >
How to add a custom HTTP header to ajax request ... - Edureka
To add a header to every request then use the beforeSend hook with $.ajaxSetup(): $.ajaxSetup({ beforeSend: function(xhr) { xhr.setRequestHeader ...
Read more >
Error: Ajax is not a function - Educative.io
AJAX( Asynchronous JavaScript And XML) is a set of web development techniques that uses many web technologies on the client-side to create asynchronous...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found