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

Add feature to catch errors in a production build for compatibility with external error tracking #11666

Open
ssmulders opened this issue Sep 16, 2020 · 3 comments

Comments

@ssmulders
Copy link

ssmulders commented Sep 16, 2020

What problem does this feature solve?

Currently all warnings are suppressed when Vue is built with process.env.NODE_ENV === production. However, many warnings are more severe than a warning - they break functionality. Duplicate keys are a good example. These are hard to filter out in a development environment because the production data could be different.

I'm currently working on a project where parts of the API and corresponding data are over 15 years old.

This means that when a user triggers an error, we're flying blind. No errors are reported. We recently implemented Sentry (which we already ran for Laravel) but again, no errorHandler or warningHandler is triggered.

What I would have liked was a way for us to see the error in production, but not show it to the user in their console. The error and warning handlers are perfect for this purpose, but lack this feature.

After extensively digging through the code and making alterations I've been able to create a production build that outputs warnings and errors. Without activating development features (like devtools, perf traces etc.) - just the warnings. No loss in performance. But it took tweaking both the Vue core files and the component-compiler-utils.

Still, it's possible, and for us, running Vue at scale, with many unknown variables - it's a must have. With these Sentries (or whatever bug tracker someone would choose) it's easy to quickly zero in on production bugs. So I'd love to improve on our solution, push it to the main repo and give back to your awesome framework :-)

What does the proposed API look like?

My proposal is to add a new process.env variable called DEBUG_LEVEL, WARN_LEVEL or something along those lines. Maybe a config setting. Something simple. With it you can pick your desired verbosity. When set to FULL, it's identical to the development build. When set to HANDLER it will only trigger custom handlers (which would then be where you'd call the Sentry / error tracker). This allows for more granular control over what is triggered, and how it's shown. And then the final setting would be NONE. Which would be identical to the current production build.

Currently the process.env.NODE_ENV controls both the warnings and the debug tools. My proposal is to separate the two.

I've already done most of the leg-work. With your thumbs-up I will clean things up, write tests and push it to the dev branch.

@posva
Copy link
Member

posva commented Sep 16, 2020

This probably should go through a detailed RFC (vuejs/rfcs)

@ssmulders
Copy link
Author

Will do. Currently still exploring and mapping the full scope of the issue. Even compile errors get ignored leading to non-functioning output without any feedback. To me, this feels weird. Granted, compile errors will surface in a local dev build. But still, if you run a CI/CD pipeline with a build test (like we do), it undeservedly passes.

@ssmulders
Copy link
Author

Still working on this. Another thing I discovered is the lack of warning / debug information on IE11 due to the usage of Proxy. One of the few things you can't polyfill. The errorHandler works, but the warningHandler, doesn't - it's unsupported. Couldn't find any mention of this in the documentation.

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

No branches or pull requests

2 participants