{"record":{"id":"418d7482a2c4163a","repo":"earendil-works/pi","slug":"session-locked","errorCode":"session_locked","errorMessage":"Session runtime is terminating: ${id}","messagePattern":"Session runtime is terminating: (.+?)","errorType":"error_code","errorClass":"PiServerError","httpStatus":null,"severity":"error","filePath":"packages/server/src/sessions.ts","lineNumber":190,"sourceCode":"\t\tconnection: ConnectionState,\n\t\tlive: LiveSession,\n\t\toperation: () => Promise<void>,\n\t): Promise<SessionSnapshot> {\n\t\tlive.operationCount += 1;\n\t\ttry {\n\t\t\tawait operation();\n\t\t\treturn this.forConnection(await this.broadcastSnapshot(live), connection);\n\t\t} finally {\n\t\t\tlive.operationCount -= 1;\n\t\t\tthis.scheduleMaybeDispose(live);\n\t\t}\n\t}\n\n\tprivate async acquire(id: string, acquireRuntime: () => Promise<PiSessionRuntime>): Promise<LiveSession> {\n\t\tfor (;;) {\n\t\t\tconst existing = this.liveSessions.get(id);\n\t\t\tif (existing) {\n\t\t\t\tif (existing.terminal) throw new PiServerError(\"session_locked\", `Session runtime is terminating: ${id}`);\n\t\t\t\tif (existing.disposing) {\n\t\t\t\t\tawait existing.disposing;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\treturn existing;\n\t\t\t}\n\t\t\tconst opening = this.openingSessions.get(id);\n\t\t\tif (opening) return opening;\n\t\t\tconst pending = this.create(id, acquireRuntime);\n\t\t\tthis.openingSessions.set(id, pending);\n\t\t\ttry {\n\t\t\t\treturn await pending;\n\t\t\t} finally {\n\t\t\t\tif (this.openingSessions.get(id) === pending) this.openingSessions.delete(id);\n\t\t\t}\n\t\t}\n\t}\n","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/server/src/sessions.ts#L172-L208","documentation":"Error \"Session runtime is terminating: ${id}\" thrown in earendil-works/pi.","triggerScenarios":"Thrown at packages/server/src/sessions.ts:190 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The session runtime is shutting down; create a new session instead of reusing a terminating one."],"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"}