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

Restart a language runtime after exit #647

Closed
Tracked by #1425
jmcphers opened this issue May 30, 2023 · 7 comments
Closed
Tracked by #1425

Restart a language runtime after exit #647

jmcphers opened this issue May 30, 2023 · 7 comments

Comments

@jmcphers
Copy link
Collaborator

To reproduce:

  1. Start Positron and open an R file and an R console
  2. Kill the associated ark process using a terminal to simulate a crash

You are notified that R exited:

image

But Positron is effectively no longer usable as an R IDE now: you don't get completions or diagnostics, you can't run code, etc. The same is true of Python, etc.

When a language runtime exits, we should help the user get back to a working state. That could involve asking the user if they'd like to restart or just automatically performing a restart and letting the user know (via a toast) what happened.

@jmcphers
Copy link
Collaborator Author

Some connected thoughts/ideas:

  • A crash should probably be followed by an unprompted restart (a modal dialog seems too heavy handed). A message in the console should indicate the exit code and any additional context we have. We should display a toast notification that helps users understand what just happened since a crash will often cause state to be lost.
  • We could use a modal dialog to help restart after an intentional shutdown (hey, just FYI, you can't run code or get completions till this is running again -- want to start it?)
  • We might be more or less aggressive with trying to get the runtime going again based on (a) whether the runtime is known to be the primary runtime for the project, (b) whether it is associated with any open documents or widgets, and (c) whether it is the last active runtime, such that its exit causes the total count of running runtimes to drop to zero.

@jmcphers
Copy link
Collaborator Author

jmcphers commented Oct 4, 2023

Ready for review. As of #1482, you should see the following behaviors:

  • If a runtime crashes on its own, it should be automatically restarted.
  • If you exit a runtime manually, you should see a "restart" button in the console to manually restart it.

@lionel-
Copy link
Contributor

lionel- commented Oct 5, 2023

The restart button works great.

Regarding crash handling, I'm observing somewhat confusing behaviour. In the console, I get the "restarted" message before the "exited" one:

Screenshot 2023-10-05 at 10 54 17

And I'm notified about a LSP failure:

Screenshot 2023-10-05 at 10 52 52

The LSP works fine in the new R session though. Looking at the output, it seems there is a redundant LSP session:

Screenshot 2023-10-05 at 10 54 01

@dfalty
Copy link

dfalty commented Oct 5, 2023

Testing on version 2023.10.0-6 with MacOS 13.6 I also see the same as @lionel- and the Restart works great on python as well as R.

I was confused at first when getting the messages due to the wording and ordering. After killing the process I got the three messages and I read these top to bottom and it says "R exited unexpectedly and was automatically restarted" and then the next message says "Couldn't start client Positron R Language Server". I thought before looking at the R console that it restarted and failed. Not sure if there is anything we can do here but I thought I would point it out to see if we have any control of the language here.
Image

Also, I noticed that the "Restart Python" button will appear when stopping/starting the interpreter from the drop-down menu. The button works as expected but it is a little weird they are still there when Python or R is running. I would expect them to disappear.
Image

@jmcphers
Copy link
Collaborator Author

Thanks for the feedback!

@lionel-
Copy link
Contributor

lionel- commented Oct 12, 2023

Just confirmed that the ordering issue and the lingering restart buttons are fixed.

I filed the LSP issue at #1568

It looks like we can close this one.

@dfalty
Copy link

dfalty commented Oct 16, 2023

Verified Fixed

Positron Version(s) : 2023.10.0-1269
OS Version          : MacOS 13.6 (M2)

Test scenario(s)

Verified both R and Python restart after exiting and console messages show up in the right order as expected.

  1. Start Positron
  2. Go to terminal and use ps -ax | grep ark or ps -ax | grep python to find the right process
  3. kill -9
  4. Go back to console and verify R or Python has restarted

R output

R 4.3.1 exited unexpectedly: killed with signal 9 (SIGKILL)
R 4.3.1 restarted.

Python output

Python 3.9.6 (Global) exited (exit code 0)
Python 3.9.6 (Global) restarted.

Also tested the new functionality of the Restart button appearing in both R and Python when the interpreter has stopped. It works as expected with both R 4.3.1 and Python 3.9.6. To reproduce, go to the dropdown interpreter menu and select Stop the interpreter button.
image

Found #1592 while testing functionality.

@lionel- I know you already tested this, I'm just trying out some QA process here. :)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants