stablyai/orca · error · SessionNotFoundError

Session not found: ${sessionId}

Error message

Session not found: ${sessionId}

What it means

SessionNotFoundError: during attach-only spawn, resolve() returned kind 'absent' — the session genuinely does not exist in any registered provider's inventory. Unlike 'unknown', this is a definitive answer: every provider reported and none owns the sessionId.

Source

Thrown at src/main/daemon/daemon-session-owner-resolution.ts:102

        }
        if (routed && this.routes.get(opts.sessionId) === routed) {
          this.forgetRoute(opts.sessionId, routed)
        }
      }
    }

    assertClientConnected(opts.signal)
    const resolution = await this.resolve(
      opts.sessionId,
      opts.expectedIncarnationId,
      opts.expectedIncarnationIsAuthoritative
    )
    assertClientConnected(opts.signal)
    if (resolution.kind === 'unknown') {
      throw new TerminalSessionOwnerUnverifiedError(opts.sessionId)
    }
    if (resolution.kind === 'absent') {
      throw new SessionNotFoundError(opts.sessionId)
    }
    try {
      const result = await resolution.provider.spawn(opts)
      if (
        !result.exitedBeforeSpawnReply &&
        result.id === opts.sessionId &&
        result.isReattach === true
      ) {
        this.recordRoute(result.id, resolution.provider, result.incarnationId)
      }
      return result
    } catch (error) {
      if (error instanceof SessionNotFoundError && this.providers.length > 1) {
        throw new TerminalSessionOwnerUnverifiedError(opts.sessionId)
      }
      throw error
    }
  }

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Create a new session instead of attaching (the session is gone).
  2. Verify the sessionId against current live sessions before attempting attach.
  3. If the session should have survived, confirm the owning provider/daemon is still running and hosting it.
  4. Clear stale session references in client state so attach is not retried against a dead id.

Example fix

// before: assume attach always succeeds
const r = await host.spawnAttachOnly({ sessionId, attachOnly: true })

// after: handle absent by creating fresh
try {
  const r = await host.spawnAttachOnly({ sessionId, attachOnly: true })
} catch (e) {
  if (e instanceof SessionNotFoundError) {
    await host.create({ sessionId, ... })
  }
}
Defensive patterns

Strategy: fallback

Validate before calling

// Probe before attaching to avoid the not-found round-trip
const verdict = await resolver.probe(sessionId)
if (verdict === false) {
  // session provably absent; create instead of attach
}

Type guard

import { SessionNotFoundError } from './daemon-errors'
function isSessionNotFound(e: unknown): boolean {
  return e instanceof SessionNotFoundError
}

Try / catch

try {
  return await resolver.spawnAttachOnly(opts)
} catch (e) {
  if (e instanceof SessionNotFoundError) {
    return await createFreshSession(opts.sessionId)  // fallback
  }
  throw e
}

Prevention

When it happens

Trigger: spawnAttachOnly (attachOnly: true) for a sessionId that no provider has ever created or that has already exited and been removed from all providers.

Common situations: Attaching to a session id from stale state after the terminal exited and was tombstoned; a sessionId typo; attempting to reattach after a daemon restart that did not persist the session.

Related errors


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