stablyai/orca · error · Error

No worktrees on environment ${envName}

Error message

No worktrees on environment ${envName}

What it means

The bulk-open freeze repro script first enumerates worktrees via 'orca worktree list' and refuses to proceed if the returned list is empty or not an array. Worktrees are the substrate the script fans terminal-create operations across, so with zero worktrees the parallel flood-create and switch amplification could not target anything meaningful. The guard also catches a malformed RPC payload where worktrees/worktrees.items/items are all missing.

Source

Thrown at config/scripts/live-remote-bulk-open-freeze-repro.mjs:107

  const notes = []
  const timings = new BoundedLiveFreezeHistory(120)
  const amplificationSteps = []

  console.log(
    `[live-freeze] env=${envName} create=${createCount} passes=${switchPasses} parallel=${parallel}`
  )

  const status = orcaJsonSync(['status'])
  notes.push(
    `remote version=${status.result?.runtime?.appVersion} state=${status.result?.runtime?.state}`
  )
  const local = orcaJsonSync(['status'], { local: true })
  notes.push(`local version=${local.result?.runtime?.appVersion} pid=${local.result?.app?.pid}`)

  const worktrees = orcaJsonSync(['worktree', 'list']).result
  const wtList = worktrees?.worktrees || worktrees?.items || worktrees || []
  if (!Array.isArray(wtList) || wtList.length === 0) {
    throw new Error(`No worktrees on environment ${envName}`)
  }
  notes.push(`remote worktrees=${wtList.length}`)
  amplificationSteps.push(`baseline worktrees=${wtList.length}`)

  const targets = wtList.slice(0, Math.min(createWorktreeSpan, wtList.length))
  const created = []

  // Parallel flood-terminal creates across many worktrees.
  if (createCount > 0) {
    amplificationSteps.push(`create=${createCount} parallel=${Math.min(parallel, createCount)}`)
    const createJobs = Array.from({ length: createCount }, (_, i) => i)
    await mapPool(createJobs, Math.min(parallel, createCount), async (i) => {
      const wt = targets[i % targets.length]
      const selector = worktreeSelector(wt)
      if (!selector) {
        notes.push(`create ${i} skipped: no selector`)
        return
      }

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Run 'orca worktree list' manually against the same target and confirm at least one worktree is registered before invoking the repro.
  2. Ensure the env name (envName) resolves to a fully initialized orca environment with checked-out worktrees.
  3. If the RPC shape changed between versions, update the wtList fallback chain to match the current 'worktree list' envelope.

Example fix

// before
const worktrees = orcaJsonSync(['worktree', 'list']).result
const wtList = worktrees?.worktrees || worktrees?.items || worktrees || []
if (!Array.isArray(wtList) || wtList.length === 0) throw new Error(...)

// after
const worktrees = orcaJsonSync(['worktree', 'list']).result
const wtList = worktrees?.worktrees ?? worktrees?.items ?? worktrees ?? []
if (!Array.isArray(wtList) || wtList.length === 0) {
  console.error('worktree list payload:', JSON.stringify(worktrees))
  throw new Error(`No worktrees on environment ${envName}`)
}
Defensive patterns

Strategy: validation

Validate before calling

const wtList = (await orca('worktree list'))?.worktrees ?? []
if (!Array.isArray(wtList) || wtList.length === 0) {
  throw new Error(`Pre-check: no worktrees on ${envName}; run 'orca worktree add' first`)
}

Type guard

const isNonEmptyWorktreeArray = (r) => Array.isArray(r) && r.length > 0 && typeof r[0]?.id === 'string'

Try / catch

try {
  runRepro(envName)
} catch (e) {
  if (/No worktrees/.test(e.message)) { await ensureWorktrees(envName); runRepro(envName) }
  else throw e
}

Prevention

When it happens

Trigger: Running the repro against a remote environment whose orca state has no registered worktrees, or where 'worktree list' returns an unexpected shape (no .worktrees, .items, or bare array). The fallback chain wtList = worktrees?.worktrees || worktrees?.items || worktrees || [] resolves to [] when the payload is null/empty.

Common situations: Pointing ORCA env at a fresh/uninitialized remote, a remote whose worktree index was reset, a version mismatch where 'worktree list' emits a different envelope, or an SSH target whose repo has no worktrees checked out.

Related errors


AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12). Data as JSON: /api/errors/f04f7fd6b9e7941c. Report an issue: GitHub.