-
Notifications
You must be signed in to change notification settings - Fork 31k
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
Replace --enable-source-maps
with --disable-source-maps
#38817
Comments
Runtime source maps come with performance penalties. I can hardly believe it will be acceptable to enable source maps by default even in server production environments. |
Makes sense. Maybe default to true in dev only then, by checking the |
Does Node itself currently use the |
This could be argued either way as to whether proper stack traces should be captured or not by default (even in production environments). Presumably this only has any effect if a sourcemap exists, so it seems likely those who bother to ship sourcemaps to production would want them to apply (otherwise they could just not bother shipping them).
Really the thing that makes it questionable as to whether it could be default or not is when do these performance penalties actually apply.
In my opinion it would be fine to enable by default if it only applies a performance impact in cases where one would actually require it to, i.e. in files that use |
It can impact startup time. Node.js parses source-maps on loading the JavaScript sources so that would take times.
It costs only when
Like said above, it can impact startup time if the source maps are unreasonably large.
Anything that printing errors will be affected as they are accessing
Every line in
No, errors thrown in any file will be penalized on accessing I cannot say that the impact is significant or not, as it may vary in different use cases. But small reduction can be accumulated to cause an observable slow down as source maps in node_modules must be counted. However, I believe that a programming API that enables built-in source-maps support seems more reasonable to the OP's requirement. Vite or any developer tools can determine if they would like to enable source-map-support in that process at the very start of the program. In this way, there will be no need for users to set the If a programming API sounds reasonable to you, I believe it will be a good start to work in that path. |
Yes, that sounds quite perfect actually. So Vite will be able to decide whether source maps are applied? Meaning Vite could expose a flag Btw. is there a way to access the original stack trace? Source maps are often broken and not being able to access the exact source of error is extremely painful. When the source mapping is broken, it'd be wonderful to be able to dig into the original stack trace and do the mapping myself then having no clue where the error originates. |
Sorry, but I didn't recall any means to do that without colliding the functionality provided by
May I have your elaboration on this? It will be helpful for us to resolve the problem if it could be fixed in Node.js core. |
I meant when the source map data itself is wrong, which is frequently the case. That's why being able to access the original stack trace is important for these situations when the source mapping is wrong. Debugging a broken stack trace is super painful. |
Does it impact startup time when there are no source maps? (If not, then most existing code's startup time won't be affected, right?)
In what situations would a developer/user reading (As a devops person, I expect
Personally, I'm interested in the default. Moving to Typescript, I now gripe that I must add |
This reasoning is convincing. Don't ship the sourcemaps, and they won't get used.
@legendecas I'm currently developing a website using Gatsby. I'm seeing an exception thrown like this:
However, no file exists under this name. Only |
see: #41541 for why I think it would be a bad idea to enable source maps by default. I think we'll gradually get source maps more performant over time, but people would shoot themselves in the foot if we enabled them by default. |
There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment. For more information on how the project manages feature requests, please consult the feature request management document. |
bad bot |
There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment. For more information on how the project manages feature requests, please consult the feature request management document. |
bad bot |
I'll close this then. Bumping is annoying and the consensus seems to be we're not going to enable this by default for performance reasons. |
I think there is something wrong with |
How about Node.js sets
--enable-source-maps
to true by default. If the user wants to get the real stack track, he can use--disable-source-maps
.The problem here is that tools like Vite cannot really leverage
--enable-source-maps
because it forces Vite users to set the flag--enable-source-maps
which is less than ideal. We don't want to tell Vite users "you need to use this and that flag"; we want things to just work. We are actually interested in using source map support (which is a lovely new feature!) but the flag thing is a problem, see related discussions at vitejs/vite#3300.Source map support is mostly taken care by frameworks; it is rarely implemented by the Node.js user himself. So we shouldn't leak this flag into user-land.
Also, in general, I'd argue that having source maps enabled by default seems to be a more sensible default.
The text was updated successfully, but these errors were encountered: