earendil-works/pi · error · Error
Cannot ${operation} a session while session is ${this.phase
Error message
Cannot ${operation} a session while session is ${this.phase ?? "unavailable"} What it means
Error "Cannot ${operation} a session while session is ${this.phase ?? "unavailable"}" thrown in earendil-works/pi.
Source
Thrown at packages/coding-agent/src/client/remote-session.ts:249
this.#clearSubscriptions();
this.#handle = undefined;
this.#transcript = undefined;
const cleanup = [...this.#pendingAttachmentOperations];
if (handle) cleanup.push(handle.dispose());
this.#disposePromise = settleRemoteSessionDisposal(cleanup);
this.#notify();
this.#listeners.clear();
return this.#disposePromise;
}
[Symbol.asyncDispose](): Promise<void> {
return this.dispose();
}
async #replace(operation: "open" | "create", prepare: () => Promise<SessionLease>): Promise<void> {
this.#assertAvailable();
if (this.#handle && this.phase !== "idle") {
throw new Error(`Cannot ${operation} a session while session is ${this.phase ?? "unavailable"}`);
}
await this.#runOperation(operation, () =>
this.#trackAttachmentOperation(() => this.#prepareReplacement(operation, prepare)),
);
}
async #trackAttachmentOperation(run: () => Promise<void>): Promise<void> {
const pending = run();
this.#pendingAttachmentOperations.add(pending);
try {
await pending;
} finally {
this.#pendingAttachmentOperations.delete(pending);
}
}
async #prepareReplacement(operation: "open" | "create", prepare: () => Promise<SessionLease>): Promise<void> {
const previous = this.#handle;View on GitHub (pinned to 4af9d21d3b)
When it happens
Trigger: Thrown at packages/coding-agent/src/client/remote-session.ts:249 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of earendil-works/pi@4af9d21d3b (2026-08-24).
Data as JSON: /api/errors/3702b41246e77084.
Report an issue: GitHub.