Skip to content
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

Report compiler crashes to the client instead of silently failing #316

Open
robmwalsh opened this issue Nov 30, 2022 · 7 comments
Open

Report compiler crashes to the client instead of silently failing #316

robmwalsh opened this issue Nov 30, 2022 · 7 comments

Comments

@robmwalsh
Copy link

Is your feature request related to a problem? Please describe.

I'm having a lot of compiler crashes using scala 3. These crashes are transparent to me when using metals and only show up when running SBT in a terminal. Sometimes I'm refactoring things and don't compile my code in SBT for a while. When I finally do, I sometimes have to spend a lot of time trying to figure out which line of code is causing the crash. It'd be good if I was notified immediately when the crash occurred so I don't have to spend so long trying to figure out the cause of the crash.

perhaps somewhat related:
scalameta/metals#4652

Describe the solution you'd like

Report the compiler crash to the user in an obvious way.

I'm open to different ideas here but I'd like to see the details of the crash logged to an output, a popup error message notifying the user that the compiler has crashed, and an option to show the details (or just show the details in the output)

Describe alternatives you've considered

I run sbt in a terminal in VSCode. Having continuous compilation enabled does provide this feedback but I generally find it too noisy when I know I have a lot of errors to fix.

Additional context

The latest compiler crash I'm wasting my time on trying to recover from

image

Search terms

compiler crash

@tgodzik
Copy link
Contributor

tgodzik commented Nov 30, 2022

Thanks for reporting! This one might be tricky, but maybe we could translate it to a diagnostic? Probably could be done in Bloop and BSP servers 🤔

@adpi2
Copy link
Member

adpi2 commented Nov 30, 2022

Thanks for reporting! This one might be tricky, but maybe we could translate it to a diagnostic? Probably could be done in Bloop and BSP servers thinking

I would rather treat a compiler crash as a Json RPC error response, which I think sbt already does. So the problem here is how Metals show the error response to the user. It could show a pop-up message.

This solution would not be specific to compiler crashes and it would also handle crashes in the build tool, in a compile request, or any other request.

@tgodzik
Copy link
Contributor

tgodzik commented Nov 30, 2022

We can show that as a showMessage for sure, though would that not be a bit intrusive? Especially if there are a couple of errors in a row?

@ckipp01
Copy link
Member

ckipp01 commented Nov 30, 2022

I think one thing that's important to differentiate is errors that are coming from the code that a user can fix, and the compiler crashing. Those are two very very different things. So I hesitate to say we should capture that position and highlight it in the editor like a normal diagnostic. That gives the impression that the code is wrong, which is might actually not be. Could we do some sort of a pop up notifying the user that the compiler crashed and prompt them to create an issue for it?

It'd be amazing to just have a popup that a user could click and get the stack trace that they could use to submit in the issue.

@tgodzik
Copy link
Contributor

tgodzik commented Nov 30, 2022

It'd be amazing to just have a popup that a user could click and get the stack trace that they could use to submit in the issue.

Potentially we could automatically construct piece of code with libraries added via using directives 😅 though user would need to eliminate local class deps manually

@robmwalsh
Copy link
Author

It'd be amazing to just have a popup that a user could click and get the stack trace that they could use to submit in the issue.

Potentially we could automatically construct piece of code with libraries added via using directives 😅 though user would need to eliminate local class deps manually

Why stop there - a full minimization should theoretically be possible! (okay, I realise that's probably an idea for a PHD candidate at EFPL, but it would be nice... One can dream :p )

@robmwalsh
Copy link
Author

robmwalsh commented Nov 30, 2022

I think one thing that's important to differentiate is errors that are coming from the code that a user can fix, and the compiler crashing. Those are two very very different things. So I hesitate to say we should capture that position and highlight it in the editor like a normal diagnostic. That gives the impression that the code is wrong, which is might actually not be. Could we do some sort of a pop up notifying the user that the compiler crashed and prompt them to create an issue for it?

It'd be amazing to just have a popup that a user could click and get the stack trace that they could use to submit in the issue.

I'd love to see a warning diagnostic show up saying "this code may have caused a compiler crash" but this would probably be difficult since the position that caused the crash is never in the compiler stack trace (pet peeve of mine, besides crashing in the first place). This might be possible with incremental textDocSync but IIRC metals is using full (I.e the whole file is sent every update)

Edit: btw the "popup that a user could click and get the stack trace that they could use to submit in the issue" is pretty much what I originally asked for. The stack trace is all the detail you usually get in any, but anything else metals knows about the cause would be helpful. I think the biggest barrier to reporting crashes is the compiler team wants a minimised repro which is a big undertaking when you have no idea what's caused the crash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants