{"record":{"id":"813f4764873d8f8c","repo":"earendil-works/pi","slug":"failed-to-dispose-remote-session","errorCode":null,"errorMessage":"Failed to dispose remote session","messagePattern":"Failed to dispose remote session","errorType":"exception","errorClass":"AggregateError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/client/remote-session.ts","lineNumber":63,"sourceCode":"\nexport interface RemoteSessionOptions {\n\tonListenerError?: (error: Error) => void;\n}\n\nclass RemoteSessionDisposedError extends Error {\n\tconstructor() {\n\t\tsuper(\"Remote session is disposed\");\n\t\tthis.name = \"RemoteSessionDisposedError\";\n\t}\n}\n\nasync function settleRemoteSessionDisposal(cleanup: readonly Promise<void>[]): Promise<void> {\n\tconst results = await Promise.allSettled(cleanup);\n\tconst errors = results.flatMap((result) =>\n\t\tresult.status === \"rejected\" && !(result.reason instanceof RemoteSessionDisposedError) ? [result.reason] : [],\n\t);\n\tif (errors.length === 1) throw errors[0];\n\tif (errors.length > 1) throw new AggregateError(errors, \"Failed to dispose remote session\");\n}\n\nexport class RemoteSession {\n\treadonly #client: PiClient;\n\treadonly #onListenerError: ((error: Error) => void) | undefined;\n\t#lifecycle: RemoteSessionLifecycle = { status: \"unbound\" };\n\t#handle: SessionLease | undefined;\n\t#transcript: TranscriptState | undefined;\n\t#unsubscribeSnapshot: Unsubscribe | undefined;\n\t#unsubscribeEvents: Unsubscribe | undefined;\n\treadonly #listeners = new Set<(state: RemoteSessionState) => void>();\n\treadonly #pendingAttachmentOperations = new Set<Promise<void>>();\n\treadonly #activeOperationStates = new Set<RemoteSessionLifecycle>();\n\t#disposePromise: Promise<void> | undefined;\n\t#resolveDisposeSignal: () => void = () => {};\n\treadonly #disposeSignal = new Promise<void>((resolve) => {\n\t\tthis.#resolveDisposeSignal = resolve;\n\t});","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/coding-agent/src/client/remote-session.ts#L45-L81","documentation":"Error \"Failed to dispose remote session\" thrown in earendil-works/pi.","triggerScenarios":"Thrown at packages/coding-agent/src/client/remote-session.ts:63 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4af9d21d3b4d664e4a29fcabfec85171077248e3","analyzedAt":"2026-08-24T13:07:14.692Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}