-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Source Map Line Numbers Are Wrong #21904
Comments
Nevermind ... stopping and restarting my devsite seems to have fixed things. It'd still be nice to learn how to try other webpack settings (of any sort, not just devtool) with Next.js, if anyone wants to share, but I'll close this issue since even I can't reproduce it now. |
Re-opening: this is an odd one. When I go from my index page to the page causing the error, I get a normal stack trace with correct line numbers. But when I go straight to that problem page (eg. by reloading while on it), I get the incorrect stack trace. However, I discovered that in either case the correct stack trace does get logged in the terminal (where I'm running the devsite)! This further makes me think it's a sourcemap/devtool issue, as it is only in the browser that I see incorrect stack traces (although I can't explain why even the browser gets them correct when I come from another page). Is there any further debugging info that I can provide that will help (short of uploading my whole app)? |
This can also be reproduced using the Next.js tutorial or just create-next-app. Simply add a "throw new Error()" to ./pages/api/hello.js . Then refresh that page and watch the console. I've confirmed this on Mac and Linux. And on Next.js 10.x and 11.0. For some combinations of device and configuration, you might need to add an import at the top of hello.js to reproduce the line number mismatch. You can see a bit more detail here. I assume this is related to webpack and babel. I've tried a variety of guidance provided on the web and so far nothing fixes this. I'm also seeing that if one adds code there to grab a stack trace there and snoop it, it's not the same trace as on the console, but neither of them are correct. I assume that means that there is code in Next.js somewhere that is adjusting the line numbers before rendered on the console, but still not getting it right. I'm willing to fix/update that code if someone can point me to it. |
Still an issue as of |
Other reports of this issue: |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
What version of Next.js are you using?
10.0.5
What version of Node.js are you using?
15.4.0
What browser are you using?
Chrome
What operating system are you using?
Linux
How are you deploying your application?
I'm having the problem in a dev environment; deployment is irrelevant
Describe the Bug
Basically it seems bug #2285 is back. If I get an error from actual line 24 of a file, the stack trace generated shows it coming from line 28 ... which is an empty line in the original source.
I've often seen this sort of thing when using the "wrong" sourcemap settings in Webpack, and I'd be more than happy to try cycling through all the various options to report back which one results in the correct line numbers ... only I have no idea how to tell Next.js what source map settings to give to Webpack.
Expected Behavior
When I get an error in dev, the line number should correspond to the line number in the file (or at least, after the browser translates that line through the source map).
To Reproduce
I'm observing this issue in the middle of a larger app, which I can't submit. However, the one interesting part is that it's coming from a local shared library.
In other words, I have project Foo, and also project Bar in the same folder. Bar has the code for the function (with the incorrect stack trace), but said function is called by Foo. Foo is able to do this because I did
npm i ../Bar
.I realize this is a specific case that others might not have, and again I'm happy to debug on my end to try and get find the correct
devtool
(https://webpack.js.org/configuration/devtool/) to resolve it ... I just need to know how I can use differentdevtool
settings with Webpack when using Next.jsThe text was updated successfully, but these errors were encountered: