Guides

Track and wait for operations

Wait for asynchronous work and recover its result

An operation records work such as creating, branching or deleting a resource. Use its ID to follow the result without starting the work again.

You need the editor or admin role in your workspace. The examples use the CLI. Over MCP, an agent does the same with list_operations and get_operation. The name demo-ops must be free in that workspace.

Wait with the command

Create a computer with the platform defaults and wait for it to finish:

nevia new demo-ops --wait
nevia status demo-ops

For asynchronous creation, --wait follows the operation until it finishes or fails. On success, status shows ready with no pending transition. See Create a computer for image and configuration choices.

If the wait times out, the operation keeps running. Continue waiting by ID.

Find and wait for an operation

List recent operations in your workspace:

nevia ops

Find the computer.create row whose RESOURCE matches the computer ID that nevia status demo-ops prints. The row shows the operation ID and state. To list only running work:

nevia ops -f state=running

Copy the ID from the OPERATION column. Replace 01d4cnjm89yk0r3xtv80dy0x7by below with that ID:

nevia wait 01d4cnjm89yk0r3xtv80dy0x7by --timeout 10m

On success, the command reports finished. Check the computer again with nevia status demo-ops. If the operation failed, read the reported error and the computer's current state before you decide what to do.

You can also wait on an operation ID from an earlier command or from an operation_in_progress error. Waiting again after a timeout picks up the same work and doesn't restart a failed operation.

If authentication still fails after the CLI refreshes credentials and retries, the command stops, but the operation keeps running. With a stored login, sign in again, then wait on the same operation:

nevia login
nevia wait 01d4cnjm89yk0r3xtv80dy0x7by --timeout 10m

Replace the example operation ID with yours. With a private key, run the wait command again to obtain a fresh token. If using NEVIA_TOKEN, replace its expired token first.

Recover after losing the response

The CLI automatically retries eligible requests during the command. If it still cannot confirm the result, or the command was interrupted, check the resource before running another create:

nevia status demo-ops
nevia ops

Use the same workspace as the original command. If you have changed workspaces, add --workspace with the original workspace's name or ID to both commands.

If the computer exists, match its ID to the operation's RESOURCE column and follow the operation with nevia wait. If the computer is already ready with no pending transition, creation is complete and there may be no operation.

If creation failed, inspect the reported error before deciding whether to delete the failed resource and create another. If you cannot establish the outcome, do not assume the request failed just because its response was lost.

Each new invocation of nevia new starts a separate create request. It does not resume the previous command. With a generated name, repeating the command can create another computer. See Operations and idempotency for automatic retry guarantees.

Clean up

Once creation has finished, delete the example computer and its data:

nevia rm demo-ops --yes --wait

The command reports that the computer was deleted.

For filters, see nevia ops. For wait options, see nevia wait. The same approach works when creating a database.

On this page