-
Notifications
You must be signed in to change notification settings - Fork 193
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
Error Overlay Shows Un-Source-Mapped Lines #226
Comments
Hi, can you provide a bit more insight what browsers you're running on? This most likely are related to how we consume webpack call stacks currently, but might be also caused by discrepancies between browsers' interpretation of sources and webpack's source maps. |
Google Chrome, latest version: 86.0.4240.75 (Official Build) (64-bit) That's on Linux ... but I'd be surprised if Linux Chrome handles source maps differently from (say) Mac Chrome, as both are *nix. |
Is there any further data I can provide? |
To add to this, and admittedly I am not sure if I am doing something wrong so if there is a way to display better error messages please let me know. But I've also noticed the error messages I get while developing are not usually helpful. Compared to create react app, I can click on the error message and it will take me to the spot where I errored in my code in my editor. It does seem like I get pointed to the webpack bundle in most cases where my error is and even setting In my code I did this: function TestComponent() {
const forceError = {key: "value"}
return <div>{forceError}</div>
} Which will force and error like this on this overlay: vs create react app: It doesn't show me the exact code but it does get the line number correct on where my error is. In the first one it shows what file the error occurred in but not the correct line number. It only shows the line number of the compiled code even with Maybe this package should support this? https://www.npmjs.com/package/react-error-overlay Or maybe allow for someway to change the error overlay so it can be swapped out. |
OK, so let me address this properly. This issue is only addressing RUNTIME errors (i.e. when the browser executes code, not when Webpack compiles). For runtime errors, this behaviour as of now, is the INTENDED behaviour. It is not perfect, it is not pretty and it is not the best experience, but it is always correct - as we directly consume the error object thrown in the browser, and map out the stacks as is. Yes, even if you provide source maps, the error stacks thrown by the browser are still pointing to the un-mapped sources. So how does others achieve their experience? Well, turns out the "good" error overlays does an extra step - fetches your source map and enhances the stack traces with their original locations. For that to work, CRUTIAL assumptions are needed to be satisfied:
For us, these assumptions are simply too strict - we support multiple Webpack socket integrations with custom paths and servers under proxies, we do not have a constrained file system, we cannot inject middleware in users' setup, etc. If we needed to properly support source-mapped error stack traces, we would have to:
As for React component stacks, they are not officially supported by React in any means (CRA is using a very stripped down proposal of the I would love to make the experience much better, but in the end I have not implemented this because of the shear amount of R&D and API-surface to cover. It is still on my radar and I would love to work on it, but until all other more important issues are fleshed out (like bugs in the actual refresh runtime) I probably wouldn't touch this - PRs are always welcomed though :) |
You can always use the However, if you want to use Their middleware setup: |
@pmmmwh -- I was wondering if you had a vetted workaround here to wire up a different overlay to resolve this issue. I fiddled with a couple of different options listed but couldn't get settings to line up to get proper source-map support working with this plugin. Thanks in advance for any help here! |
I'm using this plugin with the following config (irrelevant parts omitted):
When I get an error, in the error overlay I see line numbers from the webpack-generated source code ... not the source-mapped line numbers:
But in my console I can see the correct (ie. source-mapped) line numbers:
It seems to me Webpack knows what source map approach I'm taking ... and so this plugin ought to be able to also?
P.S. I don't think it matters, but this is all through the Webpack dev server middleware, not the standalone Webpack.
The text was updated successfully, but these errors were encountered: