earendil-works/pi · error · PiDisconnectedError
Pi client is disconnected
Error message
Pi client is disconnected
What it means
Error "Pi client is disconnected" thrown in earendil-works/pi.
Source
Thrown at packages/client/src/client.ts:228
const generation = this.#sessionLeaseGenerations.get(sessionId) ?? 0;
this.#sessionLeaseGenerations.set(sessionId, generation);
let state: SessionLeaseState = "active";
let releasePromise: Promise<void> | undefined;
const refreshState = () => {
if (
(state === "active" || state === "releasing") &&
this.#sessionLeaseGenerations.get(sessionId) !== generation
) {
state = "invalidated";
}
};
const isActive = () => {
refreshState();
return state === "active" && this.#state.isSessionAttached(sessionId);
};
const assertActive = () => {
this.#assertNotDisposed();
if (!this.connected) throw new PiDisconnectedError();
if (!isActive()) throw new PiSessionDetachedError(sessionId);
};
const release = (relinquishOnFailure: boolean): Promise<void> => {
refreshState();
if (state === "released" || state === "invalidated") return Promise.resolve();
if (releasePromise) return releasePromise;
assertActive();
state = "releasing";
releasePromise = (async () => {
const count = this.#sessionLeaseCounts.get(sessionId) ?? 0;
if (count <= 1) {
const detachment = this.#request({ command: "detach", sessionId }).then(() => undefined);
this.#sessionDetachments.set(sessionId, detachment);
try {
await detachment;
this.#releaseSessionLease(sessionId, token);
} finally {
if (this.#sessionDetachments.get(sessionId) === detachment) {View on GitHub (pinned to 4af9d21d3b)
Solutions
- Reconnect the Pi client before issuing requests.
When it happens
Trigger: Thrown at packages/client/src/client.ts:228 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/201776fcf2ff7c58.
Report an issue: GitHub.