bugsnag / bugsnag-js

JavaScript error handling tool for BugSnag. Monitor and report JavaScript bugs & errors.
https://docs.bugsnag.com/platforms/javascript
MIT License
838 stars 252 forks source link

@bugsnag/plugin-vue is throwing: TypeError: Cannot read properties of undefined (reading 'errorHandler') #2150

Open brunomonteiro-asknicely opened 1 month ago

brunomonteiro-asknicely commented 1 month ago

Describe the bug

The bugsnag-vue.js file is using Vue 2 syntax in a Vue 3 project due to a problematic if check. This then causes Bugsnag to try to access Vue.config in a Vue 3 project where global config is not available anymore.

This issue was also reported here, but it was closed due to lack of activity.

Problematic line seems to be this one. I believe a simple update to check Vue.version should fix it.

Steps to reproduce

  1. Install Vue 3 via package.json
  2. Import Vue 3 via CDN in the html file
  3. Follow the instructions to install Bugsnag in a Vue app

Environment

Example Repo

Error messages: ``` TypeError: Cannot read properties of undefined (reading 'errorHandler') at _$vue2_3 (bugsnag-vue.js:82:1) at BugsnagPluginVue.load (bugsnag-vue.js:141:1) at Client._loadPlugin (bugsnag.js:1704:1) at eval (bugsnag.js:1592:1) at eval (bugsnag.js:338:1) at _$reduce_17 (bugsnag.js:7:1) at _$map_16 (bugsnag.js:337:1) at new Client (bugsnag.js:1591:1) at Object.createClient (bugsnag.js:3268:1) at Object.start (bugsnag.js:3285:1) ```
brunomonteiro-asknicely commented 1 month ago

Just as an update: if I go to my node_modules folder and manually change the code to

if (this.Vue.version[0] === '2') {

it works fine!

clr182 commented 3 weeks ago

Hi @brunomonteiro-asknicely

Thanks for sharing this workaround.

We now have an item on our backlog aimed at fixing this issue. While we don't have a clear ETA on the release of this functionality, we will be sure to update you once we have more information to share!

brunomonteiro-asknicely commented 3 weeks ago

Thanks @clr182 ! Until this fix is released, we can't really use Bugsnag since the change in node_modules is not a realistic solution for our CI environment. Will keep an eye here and appreciate the update when that is done.