Subscribe on changes!

Error handler info parameter is number in production (string in types)

avatar
Apr 6th 2023

Vue version

vue@3.2.47

Link to minimal reproduction

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

Steps to reproduce

https://vuejs.org/api/application.html#app-config-errorhandler says the info parameter is a string.

From reproduction link:

  1. run vite build to build production version
  2. run vite preview
  3. look at the console -> it says error info: 0, which is a number, but should be a string

From stratch

  1. attach global error handler in the app and log the info into console there
  2. add some purposeful error into any vue file
  3. build the app for production
  4. run the app and look at the console

What is expected?

Either the type should be a string|number, or the runtime version should give a string info

What is actually happening?

type of info is string in developement and number in runtime.

System Info

No response

Any additional comments?

No response

avatar
Apr 6th 2023

The strings are replaced with const enum numbers in production builds to reduce bundle size. You can check the corresponding full message here: https://github.com/vuejs/core/blob/main/packages/runtime-core/src/errorHandling.ts#L42-L59

We should document this behavior.