-
Notifications
You must be signed in to change notification settings - Fork 2k
Remove problematic Error.prepareStackTrace implementation #4399
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
Conversation
… sure that it never throws. Resolves jashkenas#4391.
|
I’m not sure how to test your changes. Do you have some code that shows the previous version working as intended, that we could see still working in your revised version per this PR? |
|
The way to fix this is not to |
|
@GeoffreyBooth there are two existing tests in
I confirmed that modifying @jashkenas I agree that what you suggested would be an improvement, but I think that this pull request would still be valid, since it is imperative that |
|
It might be "imperative" — but we should never fix a thing the wrong way when it's easy to fix it the right way. |
|
@jashkenas I'm not ever opposed to doing it the "right way", but not being intimate with this project means I don't necessarily know what that would be. You say it is easy, so is this something that you plan to implement? I could take a stab at it, but you'd have to point me in the right direction to make sure you get what you want. How would you do the environment detection (like this?)? At what level do you care about the environment ( |
|
Sure, happy to point. From a quick glance, it looks like a lot of the source-mapping / error stuff was added pretty sloppily. They're reusing In addition Instead — if CoffeeScript is operating in "run" mode, we should be storing sourcemaps in memory for every script we compile, and referencing them if we need them. Not compiling a file twice, to get a sourcemap as a side effect. |
|
@jashkenas did you intend to close this? I agree source maps in general could be handled better, but perhaps there’s a more targeted solution that can address @murrayju’s issue without needing to refactor source maps more generally.
I gather you’re saying this because we should only be patching where we need to. Is there a way to determine if |
I did — because adding a
I don't know.
It should definitely never throw an exception. It should also not be compiling code. |
@jashkenas That depends on your definition of the problem. The problem for me is that the application is totally broken at load time. This is a major problem, not just some obscure stack trace debugging thing. The fact that Although this is due to some obscure interaction between requirejs, q, and coffee, and people are less likely to encounter it, it is still a critical issue. I think that this pull request (adding a There is a separate, but less critical issue with this entire stack trace implementation. Unfortunately, I don't think I have the time to address this properly right now, because frankly this is not a priority for my project. I think this concern should be handled in a separate ticket. To echo what @GeoffreyBooth said, if you are unwilling to accept the I also want to mention that this problem did not exist in v1.10, and was somehow introduced in v1.11. |
If it should never throw an exception, then what’s the problem with wrapping a |
|
A couple of thoughts in no particular order:
That's just a (pretend I'm using less melodramatic, emotional words here) completely insane way to write JavaScript. |
My production code does not run coffee. It is the build process that is broken by this.
Yes I do have a fork, but when pulling dependencies with npm, this involves the painful process of publishing a package with a different name... all just to add a few lines of code.
I am 100% in favor of this. Please do this.
I mostly agree with this sentiment in general, but in this particular case I'm just trying to be pragmatic. We are talking about the implementation of
Right, and this is a case where you should absolutely not be crashing the program. This is like throwing in a constructor... something you should never do. |
|
It sounds like we're in agreement — let's remove |
|
@murrayju do you mind revising this pull request to remove |
|
Sounds good, yes I can do that. |
|
@GeoffreyBooth @jashkenas, I pushed another commit to the same branch, but it didn't show up here (presumably because the pr is closed). Do you want to re-open it, or should I make a new pr? |
|
@murrayju Please try now. |
|
@GeoffreyBooth that worked, I see the new commit here now. @jashkenas please review! |
|
I thought we were just removing |
|
Yes, I also removed the two helper functions that were internally scoped and not otherwise referenced. |
|
If you make this change, it's going to piss off anyone who was relying on the stack trace ... but go for it. |
|
I actually question if this code was doing anything useful. The tests that I removed were actually still passing without the code in there, and as far as I can tell in some limited testing, the output of stack traces is unchanged. |
|
Thanks for bearing with us @murrayju. |
|
Thanks guys. Any ETA for when this will make its way onto npm? |
|
It’s live now. |
|
Even if you don't want to run |
|
@davibe @murrayju if anyone would like to restore stack trace line numbers in a safe way, along the lines that @jashkenas outlined above, we would be very interested. |
to make sure that it never throws. Resolves #4391.