Skip to content

fix(stop): skip stop request when instance is already stopped - #536

Open
kirtiip20 wants to merge 1 commit into
mainfrom
BREV-13031/skip-stop-when-already-stopped
Open

kirtiip20 wants to merge 1 commit into
mainfrom
BREV-13031/skip-stop-when-already-stopped

Conversation

@kirtiip20

Copy link
Copy Markdown

Problem

brev stop sends a stop request even when the VM is already stopped following a failed start. If the provider rejects the request, the environment moves to stopping_failed, preventing the user from starting it again.

Root cause

stopWorkspace in pkg/cmd/stop/stop.go sent the stop request without checking whether the instance was already stopped.

Changes

pkg/cmd/stop/stop.go:

  • Check whether the workspace status is Stopped before sending a stop request.
  • If already stopped, print "Instance is already stopped." and return without sending the request.
  • Suppress the message when the output is piped.

pkg/cmd/stop/stop_test.go:

  • Added TestStopWorkspace_SkipsStopRequestWhenAlreadyStopped.
  • Added TestStopWorkspace_SendsStopRequestWhenRunning.

Testing

The pkg/cmd/stop tests pass locally, including the two new cases.

  • Running brev stop on an environment in starting_failed with its VM already stopped prints "Instance is already stopped." and sends no stop request.
  • Running brev stop on a running instance sends the stop request as before.

Output

Environment in starting_failed with its VM already stopped:
Before:

$ brev stop teststop
Stopping instance teststop.
Note: this can take a few seconds. Run 'brev ls' to check status

After:

$ brev stop teststop
Instance teststop is already stopped.

@kirtiip20
kirtiip20 marked this pull request as ready for review November 16, 2026 05:59
@kirtiip20
kirtiip20 requested a review from a team as a code owner November 16, 2026 05:59
@kirtiip20 kirtiip20 self-assigned this Nov 17, 2026
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

Successfully merging this pull request may close these issues.

2 participants