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

Default error handler should not catch error in PROD when happening in an async function #7874

Closed
AlexandreBonaventure opened this issue Mar 10, 2023 · 2 comments

Comments

@AlexandreBonaventure
Copy link
Contributor

AlexandreBonaventure commented Mar 10, 2023

Vue version

3.2.47

Link to minimal reproduction

https://stackblitz.com/edit/vitejs-vite-guvjj7?file=src/main.js

Steps to reproduce

Throw an error in an async function triggered in a vue component
(SFC playground has a special errorCaptured hook, so this is why I'm using Stackblitz)

Change vue PROD/DEV mode in Stackblitz with:

"scripts": {
    "dev": "NODE_ENV=production|development vite",
    .....
}

What is expected?

Error thrown in async code won't crash the application so in my opinion Vue should not catch these and let them propagate (up to uncaughtexception handler). Since this behaviour is not consistent between prod and dev, this is a bit counter-intuitive. I know popular error tracking SDK offer built-in implementations for Vue, but a lot of tools are instrumenting the uncaughtexception handler.

What is actually happening?

Here https://github.com/vuejs/core/blob/main/packages/runtime-core/src/errorHandling.ts#L164, in production mode errors are caught and simply logged to the console.log, so runtime errors are less disruptive

in DEV the error is thrown
Imgur

in PROD (`NODE_ENV=production vite ) the error is not thrown, just logged
Imgur

System Info

No response

Any additional comments?

Workaround is to use the error captured handler https://vuejs.org/api/application.html#app-config-errorhandler

NB: Just my 2cents, but to open up the discussion: catching the error on production even for synchronous code is a lot of handholding, I'm wondering if the default behaviour should be let the error be thrown. I understand the idea of being less disruptive for potential issues but at the same time it's giving away some power for developers that are relying on default error behaviour.

@ken1987
Copy link

ken1987 commented Jun 21, 2023

try app.config.errorHandler

@edison1105
Copy link
Member

closed via f476b7f

@edison1105 edison1105 closed this as not planned Won't fix, can't repro, duplicate, stale Sep 6, 2024
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