evidence-dev/evidence-vscode

Preview window shows up if you kill server before it has finished launch

archiewood opened this issue · 5 comments

Steps To Reproduce

  • Evidence: Start Dev Server command
  • (quickly) Evidence: Stop Dev Server command

Environment

  • VSCode Extension version (Check in VSCode Marketplace): 1.1.2

Expected Behavior

Nothing

Actual Behaviour

Opens Markdown Preview window

CleanShot 2023-06-13 at 16 46 16

Ok it looks like the reason this happens is that the start server command is already running and so even though we kick off the stop server command, some parts of the start server command continue to run.

I think there is a better fix for this, but for now a guaranteed solution is to remove the "stop server" command from the status bar when it is in "starting" state. In which case, you would have to always wait for it to finish starting before you can stop it.

a guaranteed solution is to remove the "stop server" command from the status bar

this still has the same issue if you kill the command from the terminal, which i might be inclined to do if there was no button to mash

Good point.

Alright I think we can actually solve this by making the stopServer command asynchronous, then setting the _running flag to false at the right time to avoid any other server-starting activities being run.

This wouldn't solve the terminal/commands mismatch, but at least would make the VS Code option a reliable way to shut it off mid-start

Only outstanding concern is if you use the stop server shortcut

It works with the stop server shortcut since it uses the same command as the buttons - just tested to make sure. So I think it's only the terminal commands that it can't correct for at the moment