-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Errors in lazy loaded components are not propagated and have no source map support #1798
Comments
Timely, we ran into this today as well. |
I don't see why you would have an error raised outside the component code but inside of the component file. If it's raised inside, you can see the actual code for the component and Vue is able to catch it but otherwise, it cannot. const Hello = () => import('../components/Hello')
.catch((err) => ({
render: h => h('div', [
h('h1', err.name),
h('pre', err.stacktrace)
])
})) (or similar) |
@posva the error thrown in my example represents an unexpected error; I should have clarified that part. When we import libraries or other components it's not unusual to have code between the |
When does that happen? By accident when developing? |
Examples of modules I've seen importing which will sometimes throw: import fs from 'fs';
const MY_DATA = fs.readFileSync('./myFile.csv');
export default {
getUsers() {
// use MY_DATA
}
};
... The example above will throw on import if const HASH = window.btoa('asdf')
export default {
getSomething() {
// use HASH
}
};
... The example above will throw when using the code in a WebWorker or in Node.js. It will work as expected in the browser. The point I'm trying to make is that it's not just typos during development. There are bugs in the logic that could throw on import and there are missed conditions or environments that can make a module throw on import. |
First, let me say thanks for the excellent work here. We love Vue and vue-router and none of this is possible without the hard work and dedication of people like you.
This is definitely true, with an emphasis on should. The point of this issue is the case where you unfortunately haven’t, or otherwise made a mistake. People make mistakes in both dev and Prod, and having clear stack traces in Prod when you’ve unfortunately missed a catch or errBack somewhere is even more critical. Please reconsider closing this issue. |
If a module throws when imported, it will throw in dev, otherwise, it will be during component's life and therefore caught by Vue. In any case, you should be able to get better stack traces if you have sourcemaps |
On our end this occurred during Server Side Rendering, someone included a polyfill that was not node compatible that was being included in an imported component. |
There are situations where it doesn't fail in dev where it may in PROD: fixtures / flaky network / testing only happy paths, etc etc. There are many ways in which a module does something on import that can fail in an unexpected way, and the developer in dev didn't catch it, and only starts failing in prod at like 4AM Saturday morning, exactly when you most dearly need those clear stack traces. If there is nothing vue-router can do here to help that, or if this is considered an unlikely scenario, I get that. But it definitely does happen. |
To echo @mikesherov: the work that you're doing on Vue @posva is amazing and is greatly appreciated. This library, like others in the Vue ecosystem is reliable and a pleasure to work with because of the work that you do. I now see how confusing this issue is without a complete and proper repro; which I'm working on and will post here. The issue that motivated me to report this is with this code in SSR. Using The issues we are seeing are:
Once again, I'll provide a minimal repro with SSR for this. |
@nemtsov this was the polyfill that was added if you need something that will easily blow up in node :) https://github.com/jimmywarting/FormData |
I'll wait for the ssr repro @nemtsov but I'm not sure if we'll be able to do something in vue-router or even vue. We'll see |
Ok. I figured out the first of the two issues, where the callback of The behavior that was unclear to me is that (a) Take a look at the repro here: Note the
If you uncomment the "/good" only, you'll see the So, the first one is not an issue. The second one (re source-maps) I think I'll move to Thank you @posva Edit: I've created a full repro for the second of the two issues here: vuejs/vue#6778 |
Thanks for the concise repro 🙂 |
Version
2.7.0
Reproduction link
https://codesandbox.io/s/176k2vp03
Steps to reproduce
renderToString
More info
When using VUE Router Lazy Loading, and there's an error outside of the component, the error is not propagated & the stack trace isn't cleaned up with source maps. Here's the gist of the minimal reproduction (linked):
e.g.
MyComponent.vue
createRouter.js
Error in the logs:
What is expected?
I expect the error to be propagated to the
renderToString
err in the callback and the error to be rewritten using the source maps.What is actually happening?
When rendered with SSR, the page hangs, as the error is never propagated to
renderToString
'serr
in the callback.The text was updated successfully, but these errors were encountered: