{"record":{"id":"1ebf540e380cdd91","repo":"moeru-ai/airi","slug":"unable-to-reload-missing-extension-session-sess","errorCode":null,"errorMessage":"Unable to reload missing extension session: ${sessionId}","messagePattern":"Unable to reload missing extension session: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/plugin-sdk/src/plugin-host/core.ts","lineNumber":847,"sourceCode":"    return await this.dependencies.waitFor(key, timeoutMs)\n  }\n\n  async stop(sessionId: string): Promise<ExtensionSession | undefined> {\n    const extensionSession = this.extensionSessionService.get(sessionId)\n    if (!extensionSession) {\n      return undefined\n    }\n\n    await this.cleanupExtensionSession(extensionSession)\n    return extensionSession\n  }\n\n  async reload(sessionId: string, options: ExtensionStartOptions = {}): Promise<ExtensionSession> {\n    // Reload preserves manifest/runtime intent, then performs stop + fresh start.\n    // This intentionally creates a new session identity for deterministic re-bootstrap.\n    const previousExtension = this.extensionSessionService.get(sessionId)\n    if (!previousExtension) {\n      throw new Error(`Unable to reload missing extension session: ${sessionId}`)\n    }\n\n    const manifest = previousExtension.manifest\n    await this.cleanupExtensionSession(previousExtension)\n    return this.start(manifest, {\n      ...options,\n      cwd: options.cwd ?? previousExtension.cwd,\n      runtime: options.runtime ?? previousExtension.runtime,\n    })\n  }\n}\n","sourceCodeStart":829,"sourceCodeEnd":859,"githubUrl":"https://github.com/moeru-ai/airi/blob/27111382b4a79a7e983289d6e983a06af185ed0f/packages/plugin-sdk/src/plugin-host/core.ts#L829-L859","documentation":"Thrown by ExtensionHost.reload() when no session exists for the given sessionId. Reload preserves the prior session's manifest, cwd, and runtime intent, so it requires a live session to read that state from; without one it cannot deterministically re-bootstrap.","triggerScenarios":"Calling host.reload(sessionId) after the session was already stopped (host.stop removed it), was never started, or when passing a stale/typo sessionId.","commonSituations":"Calling reload on a session that was torn down by a previous stop() or cleanup. Holding a sessionId across a restart boundary. Using reload where start() on the manifest would be correct because the prior session is gone.","solutions":["Confirm the session is still live via host.getSession(sessionId) before calling reload().","If the session was stopped, call host.start(manifest) with the original manifest instead of reload().","Avoid calling reload() concurrently with stop(); serialize teardown and restart."],"exampleFix":"// before\nawait host.stop(session.id)\nawait host.reload(session.id) // throws: session already removed\n\n// after\nconst existing = host.getSession(session.id)\nif (existing) {\n  await host.reload(session.id)\n} else {\n  await host.start(manifest)\n}","handlingStrategy":"validation","validationCode":"const session = host.getSession(sessionId)\nif (!session) {\n  throw new Error(`Session '${sessionId}' is not active. Use host.start(manifest) instead of reload.`)\n}\nawait host.reload(sessionId)","typeGuard":"function canReload(host: ExtensionHost, sessionId: string): boolean {\n  return host.getSession(sessionId) !== undefined\n}","tryCatchPattern":"try {\n  await host.reload(sessionId)\n} catch (error) {\n  if (error instanceof Error && /Unable to reload missing extension session/.test(error.message)) {\n    // session gone; fall back to a fresh start with the original manifest\n    await host.start(manifest)\n  } else {\n    throw error\n  }\n}","preventionTips":["Call host.getSession(id) before reload() to confirm the session is still live.","Do not reload a session that was already stopped; use start(manifest) instead.","Serialize stop/reload/start to avoid operating on a half-torn-down session."],"tags":["session","lifecycle","reload","not-found"],"backgroundTag":null,"analyzedSha":"27111382b4a79a7e983289d6e983a06af185ed0f","analyzedAt":"2026-08-12T18:33:34.132Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}