anomalyco/sst · error

ErrLockExists

ErrLockExists

Error message

Concurrent update detected, run `sst unlock --stage=<stage>` to delete lock file and retry.

What it means

`ErrLockExists` is returned by `Lock`/`Run` when the per-stage state lock file already exists, meaning another SST update appears to be in progress. SST serializes deployments per stage with a lock to prevent concurrent updates from corrupting state.

Source

Thrown at pkg/project/provider/provider.go:68

}

func (dt *DevTransport) Publish(input interface{}) error {
	jsonBytes, err := json.Marshal(input)
	if err != nil {
		return err
	}
	dt.Out <- string(jsonBytes)
	return nil
}

type DevSession interface {
	Cleanup() error
	Publish(json string) error
}

const SSM_NAME_BOOTSTRAP = "/sst/bootstrap"

var ErrLockExists = fmt.Errorf("Concurrent update detected, run `sst unlock --stage=<stage>` to delete lock file and retry.")
var ErrLockNotFound = fmt.Errorf("Lock not found")
var passphraseCache = map[Home]map[string]string{}

func Copy(from Home, to Home, app, stage string) error {
	reader, err := from.getData("app", app, stage)
	if err != nil {
		return err
	}
	err = to.putData("app", app, stage, reader)
	if err != nil {
		return err
	}
	reader, err = from.getData("secret", app, stage)
	if err != nil {
		return err
	}
	to.putData("secret", app, stage, reader)
	return nil

View on GitHub (pinned to a0bd20f762)

Solutions

  1. Ensure no other sst process is running against this stage, then run `sst unlock --stage=<stage>` and retry
  2. If in CI, cancel the overlapping job before retrying
  3. If locks recur from crashes, run the unlock command after each interrupted deploy

Example fix

$ sst unlock --stage=prod
$ sst deploy --stage=prod
Defensive patterns

Strategy: try-catch

Validate before calling

aws ssm get-parameter --name /sst/lock/<app>/<stage> 2>/dev/null && echo "stage locked" || echo "stage free"

Try / catch

err := sstDeploy(ctx, stage)
if errors.Is(err, sst.ErrLockExists) {
    exec.Command("sst", "unlock", "--stage="+stage).Run()
    err = sstDeploy(ctx, stage) // retry once
}

Prevention

When it happens

Trigger: Running two `sst deploy`/`sst dev` processes for the same stage simultaneously; a previous run crashed or lost network without releasing the lock (stale lock).

Common situations: CI pipeline overlapping a locally running deploy; Ctrl-C / laptop sleep during deploy leaving an orphaned lock; two teammates deploying the same stage.

Related errors


AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30). Data as JSON: /api/errors/c828366d0bc820b5. Report an issue: GitHub.