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
Better crash reporting #11304
Better crash reporting #11304
Comments
Hi, thanks for the proposal. Have you tried running ESLint with the |
Just tried that flag - here's what it looks like on ESLint 5.12.1:
On ESLint 4.19 it's just
So it does output the file name, which is good. I guess we could direct users to use the |
Basically i don’t see any reason why the:
aren’t always reported - i can’t conceive of any reason why that isnt relevant every single time. |
Isn't all of that information already inferable from the stack trace? |
The trace is from where it threw; it tells you nothing about which code it threw on. |
Sorry, I misunderstood (I thought by "the file and line it crashed on" you meant the rule file). I think it would be reasonable to always include the target filepath that caused the crash in the error message. However, I don't think it's possible to determine the line of the target file that caused the crash. |
Surely the ast node’s location, for the visitor that crashed, is available? |
We could report the AST node's location, which would help in some cases. But it could often turn out that the crash was a result of some corrupted state from some previous point in the file, which only resulted in an error being thrown at a normal-looking AST node. For example, if a rule's logic is "given some variable reference, iterate over all places where the variable was assigned", and one of the assignments does something that causes the rule to crash, then the crash might occur in the visitor where the variable is read, even though the actual cause of the crash is in the node where the variable is assigned. |
That doesn't matter; the point in the source code at which the crash occurred is invaluable in determine why the rule code crashed. |
Sounds reasonable, I'd be fine with improving the error message to include that info if anyone wants to create a PR. (Since this just modifies an error message for debugging and doesn't have semver impact, I don't think this would need TSC approval.) It would probably be better to add this information to the error object that gets thrown from |
Ok, I'm taking a stab at this. A couple of clarifying questions:
|
I would prefer to see both the code’s filename and line number always, without exception. |
Unfortunately, it looks like there wasn't enough interest from the team Thanks for contributing to ESLint and we appreciate your understanding. |
It’d be great to reopen this; this impacts the entire plugin ecosystem. |
@alexzherdev Sorry, I missed your questions. Thanks for working on this!
I agree with @ljharb that outputting both the line number and the filename is worthwhile in the event of a crash, regardless of whether the
Given that this only applies when something has crashed, I think it's fine to add lots of debugging information regardless of whether a flag like To reiterate #11304 (comment), I think this would involve adding information to a thrown error object rather than adding something like |
Sounds good. I understand this is impactful and I’ll try to find time to complete this 👍 |
Add line number to the output in the event of a rule crash
Add line number to the output in the event of a rule crash
The version of ESLint you are using.
5.12
The problem you want to solve.
When a rule crashes for any reason, it can be difficult for the users to determine which source file caused the crash - especially if they are running ESLint from the command line on a big project. We're encountering this very often after releases in eslint-plugin-react and frequently have to ask for reproduction code.
I'm filing this to double-check if anything can be done in ESLint core to improve on this.
Your take on the correct solution to problem.
It'd be ideal if before the stack trace we could output the source file name and line number that caused the crash, although I imagine at that point it wouldn't be too hard to output the actual code on that line. I'm not sure if this can be achieved within ESLint's architecture, which I'm not familiar with.
Are you willing to submit a pull request to implement this change?
Yes, although again I'm not familiar with the ESLint codebase.
The text was updated successfully, but these errors were encountered: