# Deploy command timed out? Resume it without deploying twice

Gregale · Updated 2026-12-05

Tell a local wait timeout from a failed deployment, then resume the original Gregale deployment by ID from a fresh terminal.

If your **deploy command timed out**, check whether Gregale accepted the deployment before you run it again. A timeout in your terminal or CI job is not the same as a failed build. If you already have a deployment ID, run `gregale release wait DEPLOYMENT_ID --app APP` from a fresh terminal. It watches that deployment without uploading code or starting a second build.

| What you have                                 | What to do next                                                                                                                                                                                       |
| --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| An accepted deployment ID                     | Run `gregale release get DEPLOYMENT_ID` to see the server's state, then wait on that same ID if it is still in progress.                                                                              |
| A saved deploy session but no confirmed ID    | On the machine or persistent state directory that holds the session, run `gregale release resume SESSION_ID`. It reconnects to the original attempt and can finish pending setup.                     |
| A confirmed terminal build or startup failure | Read the failing stage and its logs. Fix the cause before submitting a new deployment.                                                                                                                |
| Neither an ID nor a saved session             | Check the right app and environment's [deployment history](https://gregale.dev/docs/cli-inspect.md). Match the source, time, and any receipt you have. Don't use `latest` as proof that a deployment came from your CI job. |

## Reconnect without rebuilding

Open a new shell, authenticate to the same workspace and API endpoint, and use the **full deployment ID** from the original receipt:

```bash
gregale --non-interactive --json release wait "$DEPLOYMENT_ID" \
  --app "$APP" --timeout 5m
```

A fresh shell does not need the source checkout or the original local session when you have the ID. If the local wait times out again, check the same deployment with `release get`; that distinguishes another wait timeout from a server-side terminal state. A deployment reported as live can still be staged at 0% or in a canary. **If your original wait was for rollout completion, keep `--rollout`** on the new wait command. Do not swap it for a plain readiness wait: a canary can already be live at 1%. If you need to prove users see it, [check traffic and the serving revision separately](https://gregale.dev/articles/verify-production-deployment).

Use the separate [saved-session command](https://gregale.dev/docs/deploy-from-github.md#waiting-and-resuming) when you saved a session ID instead. Resume from the same local state directory and use the original endpoint, profile and credential. Keep the session on private storage. A new CI runner will not find files that existed only on the runner that lost its connection. A timeout before a receipt is ambiguous: do not assume the request failed just because the response never arrived.

If you actually want to stop a build rather than resume watching it, [cancel the specific deployment ID](https://gregale.dev/articles/cancel-stuck-deployment). Closing a terminal does not cancel it.

## Reproduce the interruption on a test app

[Download the Docker starter](https://gregale.dev/examples/resume-deployment-after-cli-timeout.zip). The included guard creates a **fresh internal test app** and refuses an existing slug. It needs Bash, `curl`, `jq`, OpenSSL, the Gregale CLI and an exported `FAAS_TOKEN` with app-create and deploy access in a test workspace. The starter has a `/version` route with a fixed JSON marker.

In terminal 1, from the extracted starter, submit it once. Save the receipt **outside** the source directory:

```bash
set -euo pipefail
APP="demo-resume-$(openssl rand -hex 8)"
bash create-app.sh "$APP" >/dev/null
export GREGALE_TOKEN="$FAAS_TOKEN"
export GREGALE_API_URL=https://api.gregale.dev FAAS_API=https://api.gregale.dev
RECEIPT="$(mktemp)"
ERROR_LOG="$(mktemp)"
printf 'Receipt: %s\nError log: %s\n' "$RECEIPT" "$ERROR_LOG"
gregale --non-interactive --json deploy --name "$APP" --source=worktree --no-wait --yes \
  > "$RECEIPT" 2> "$ERROR_LOG"
DEPLOYMENT_ID="$(jq -er '.id' "$RECEIPT")"
printf 'App: %s\nDeployment: %s\n' "$APP" "$DEPLOYMENT_ID"

gregale release wait "$DEPLOYMENT_ID" --app "$APP" --timeout 5m
```

While that waiter is still running, press **Ctrl+C**. This stops the local wait. Do not run another `deploy` or a cancellation command. In terminal 2, set `APP` and `DEPLOYMENT_ID` to the printed values, then run:

```bash
gregale --non-interactive --json release wait "$DEPLOYMENT_ID" --app "$APP" --timeout 5m |
  jq -e --arg id "$DEPLOYMENT_ID" '.id == $id and .status == "live"'

gregale --non-interactive --json release verify "$DEPLOYMENT_ID" --app "$APP" --path /version |
  jq -e --arg id "$DEPLOYMENT_ID" '
    .verified and .deployment_id == $id and .http_status == 200
    and (.body | fromjson) == {fixture: "resume-original-deploy"}'

gregale release list "$APP" --all
```

There should be one deployment in the fresh test app's history. Delete the disposable app and the two local receipt files when you finish.

## Keep the receipt separate from the CI wait

Split **submission** and **waiting** into separate steps. Have the first step record the deployment ID using your CI job's output or artifact mechanism before the second waits on it. Keep the ID with the app, environment, and source commit. If the waiter gets canceled, the next job can pick up that ID instead of rerunning the deploy step.

## If the submission returned no deployment ID

In JSON mode, inspect the structured error on **stderr** (the error log printed above for the demo). Keep it private. If it includes `recovery.submission_outcome`, use that field to distinguish an accepted request from a rejected or unknown one. A recovery response can also tell you that an attempt was never submitted. The absence of a recovery block is not proof that nothing was accepted.

- **Accepted:** Recover the ID or use the saved session's next command. Don't submit again.
- **Rejected or not submitted:** Read the reason before deciding whether you need a new attempt.
- **Unknown:** Inspect the original app's deployment history. A matching receipt is stronger evidence than a nearby timestamp. Resume the saved session if it exists; it can look for accepted work but cannot finish an upload that was never accepted.

Only retry an ambiguous submission with the printed `retry_flag` when the CLI supplies it. Keep the original source bytes, deploy options, account, API endpoint and selected profile unchanged. The [idempotency key](https://gregale.dev/docs/deploy-from-github.md#accept-time-checks) identifies the same logical request, not new code or settings. If the CLI supplies no retry flag and you still cannot tell whether it was accepted, do not submit again blindly.

## What we tested on Gregale

We used the downloadable fixture to create a fresh internal app, confirmed the guard refused the same name, and interrupted the local waiter while Gregale was still preparing the image. A second CLI process, running without the checkout or the original session directory, waited for the same deployment ID. That ID became live, returned HTTP 200 with the fixture marker, and was the only deployment in the app's history. The test used Gregale CLI v0.1.18-rc.394. It did not simulate a lost submission response, recover a saved session, or run a canary.

## Questions

### Does a CLI deploy timeout mean the deployment failed?

No. A timeout may only have stopped your local wait. If Gregale accepted the deployment, inspect its own state with release get before deciding whether to start another attempt.

### Can I resume a Gregale deployment from another terminal?

Yes. Authenticate to the same workspace and run gregale release wait with the original deployment ID. This observes the existing deployment without submitting another build or needing the source checkout.

### What if the deploy command did not return a deployment ID?

Use release resume with a saved session ID if you have it. Otherwise inspect the correct app and environment history and match available evidence before resubmitting.

Canonical URL: https://gregale.dev/articles/resume-deployment-after-cli-timeout

