-
Notifications
You must be signed in to change notification settings - Fork 211
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
Fix Vue 3 loop #1145
base: master
Are you sure you want to change the base?
Fix Vue 3 loop #1145
Conversation
Fix loop in vue 3
// In case the error is from the router or am helper | ||
// calling vm could generate a loop and freeze the browser | ||
// rollbar.error(error, { vueComponent: vm, info }); | ||
|
||
rollbar.error(error, { info }); | ||
|
||
if (app.config.devtools) console.error(error); | ||
} | ||
|
||
|
||
app.config.warningHandler = (error, vm, info) => { | ||
rollbar.warning(error, { info }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a more appropriate example is to grab the most relevant and common data off the component, with coalesced fallbacks to empty data.
I also think it's best to stick with the existing format of multiline conditionals. It's a style choice, but the more common one, and since that's how the example was previously styled, I think we should stick to it for consistency across the docs
// In case the error is from the router or am helper | |
// calling vm could generate a loop and freeze the browser | |
// rollbar.error(error, { vueComponent: vm, info }); | |
rollbar.error(error, { info }); | |
if (app.config.devtools) console.error(error); | |
} | |
app.config.warningHandler = (error, vm, info) => { | |
rollbar.warning(error, { info }); | |
// In case the error is from the router or a helper | |
// calling vm could generate a loop and freeze the browser | |
// Instead, we pick the relevant data off the vm instance | |
const vueComponent = { | |
name: vm.$options?.name ?? 'AnonymousComponent', | |
props: vm.$props ?? {}, | |
data: vm.$data ?? {}, | |
attributes: vm.$attributes ?? {}, | |
route: vm.$route ?? {}, | |
}; | |
rollbar.error(error, { vueComponent, info }); | |
if (app.config.devtools) { | |
console.error(error); | |
} | |
app.config.warningHandler = (error, vm, info) => { | |
rollbar.warning(error, { vueComponent, info }); |
app.config.warningHandler = (error, vm, info) => { | ||
rollbar.warning(error, { info }); | ||
|
||
if (app.config.devtools) console.log('just a warning, but!,error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency across the docs, I suggest we keep this to multiline format
if (app.config.devtools) console.log('just a warning, but!,error) | |
if (app.config.devtools) { | |
console.log('just a warning, but!, error) | |
} |
I agree that the docs should be changed. This is a fairly egregious oversight as the introductory docs for vue apps literally tell you to log in a way that will crash your application. That said I think that this should be renamed and not necessarily considered a resolution to #1126 since it only updates the docs (which we should do), but ideally |
Fix loop in vue 3
Description of the change
Type of change
Related issues
Checklists
Development
Code review