Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue Plugin Errors #1061

Closed
dts opened this issue Sep 28, 2017 · 4 comments
Closed

Vue Plugin Errors #1061

dts opened this issue Sep 28, 2017 · 4 comments

Comments

@dts
Copy link

dts commented Sep 28, 2017

Right now, this code can cause problems:

   var metaData = {
      componentName: formatComponentName(vm),
      propsData: vm.$options.propsData
    };

If vm is null (which happens on occasion for me), or if propsData contain cyclic data structures, it throws an exception during the error handler, which is unfortunate, as both errors don't get reported properly. This is my proposed change:

  Vue.config.errorHandler = function VueErrorHandler(error, vm, info) {
    var metaData = {};
    try {
      metaData.componentName = formatComponentName(vm);

      // lifecycleHook is not always available
      if (typeof info !== 'undefined') {
        metaData.lifecycleHook = info;
      }

      var propsData =vm && vm.$options && vm.$options.propsData;

      // ensure we can JSON-stringify the props, before passing them up:
      var text = JSON.stringify(propsData);
      metaData.propsData = propsData;
    } catch (x) {
      // if we have a problem above, we just don't get whiz-bang data, 
      // and we report that error as well:
      Raven.captureException(x);
    }

    Raven.captureException(error, {
      extra: metaData,
    });

    if (typeof _oldOnError === 'function') {
      _oldOnError.call(this, error, vm, info);
    }
  };
@kamilogorek
Copy link
Contributor

if propsData contain cyclic data structures, it throws an exception during the error handler

Can you provide a test example for this? Data is stringified using https://github.com/isaacs/json-stringify-safe which handles cyclic data structures as well.

@dts
Copy link
Author

dts commented Oct 2, 2017

Not sure I can at the moment (NDAs and such), but I was passing things that inherited from Vue around as props, if that is helpful. It was reporting that something didn't response to toJSON().

@ankurk91
Copy link
Contributor

This has been fixed in vue 2.5.0

@kamilogorek
Copy link
Contributor

Thanks for letting us know @ankurk91! Cheers! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants