* Stop a Coder workspace. * * Uses spawn + timeout so callers don't hang forever on a stuck CLI invocation.
(
workspaceName: string,
options?: { timeoutMs?: number; signal?: AbortSignal }
)
| 1223 | * Uses spawn + timeout so callers don't hang forever on a stuck CLI invocation. |
| 1224 | */ |
| 1225 | async stopWorkspace( |
| 1226 | workspaceName: string, |
| 1227 | options?: { timeoutMs?: number; signal?: AbortSignal } |
| 1228 | ): Promise<Result<void>> { |
| 1229 | const timeoutMs = options?.timeoutMs ?? 60_000; |
| 1230 | |
| 1231 | try { |
| 1232 | const result = await this.runCoderCommand(["stop", workspaceName, "--yes"], { |
| 1233 | timeoutMs, |
| 1234 | signal: options?.signal, |
| 1235 | }); |
| 1236 | |
| 1237 | const interpreted = interpretCoderResult(result); |
| 1238 | if (!interpreted.ok) { |
| 1239 | return Err(interpreted.error); |
| 1240 | } |
| 1241 | |
| 1242 | return Ok(undefined); |
| 1243 | } catch (error) { |
| 1244 | const message = getErrorMessage(error); |
| 1245 | return Err(message); |
| 1246 | } |
| 1247 | } |
| 1248 | |
| 1249 | /** |
| 1250 | * Wait for Coder workspace startup scripts to complete. |
no test coverage detected