Skip to main content

watchCvmState

GET /cvms/{cvmId}/state (Server-Sent Events) Watches CVM state changes in real-time via Server-Sent Events (SSE). Resolves when a completion event confirms the target status. A timeout applies to one attempt; the client retries by default without a limit. It also retries when the stream ends before completion. Cancellation aborts the watch. Parameters: Options: Returns: CvmState — the latest state received when a completion event confirms the target. The state’s raw status can differ from the derived status used for that comparison. Errors: A server error event may be followed by more events. When MaxRetriesExceededError is raised, lastServerError may contain the latest server error event data, which is also included in the error message. lastAttemptError may contain the last transport error. If retries end on a transport error without a server diagnostic, that error is thrown directly. Example — Wait for CVM to start:
Example — With abort support:
Unlike other SDK functions, watchCvmState does not have a safe variant. Use try/catch for error handling.