chatboxai/chatbox · warning · Error
Session not found
Error message
Session not found
What it means
Thrown inside the updater callback passed to chatStore.updateSession when the session with the given sessionId is not present in the store. The callback is invoked to merge reasoning provider options into the session settings; a missing session means the id is stale — the session was deleted, not yet created, or the id is wrong. This is a logic/consistency error, not a network failure.
Source
Thrown at src/renderer/components/InputBox/useReasoningControlState.ts:164
// Existing sessions persist level changes directly (see handleReasoningLevelChange);
// the patch is only needed when the session does not exist yet and will be created on
// submit. It carries every per-model draft; 'default' drafts need no entry since a
// new session starts at the default level anyway.
const settingsPatch = useMemo<Partial<SessionSettings> | undefined>(() => {
if (!isNewSession) return undefined
const byModel: Record<string, ProviderOptions> = {}
for (const [key, entry] of Object.entries(draftByModel)) {
if (entry.options) byModel[key] = entry.options
}
if (Object.keys(byModel).length === 0) return undefined
return { providerOptionsByModel: byModel }
}, [isNewSession, draftByModel])
const persistProviderOptions = useCallback(
async (sessionId: string, nextProviderOptions?: ProviderOptions) => {
await chatStore.updateSession(sessionId, (session) => {
if (!session) {
throw new Error('Session not found')
}
return {
...session,
settings: {
...session.settings,
...setReasoningProviderOptionsForModel(
session.settings,
model?.provider,
model?.modelId,
nextProviderOptions
),
},
}
})
},
[model?.provider, model?.modelId]
)
View on GitHub (pinned to 81571269ad)
Solutions
- Check that the session still exists (chatStore.getSession(sessionId)) before calling updateSession.
- Make the updater callback return undefined or a no-op when session is null instead of throwing.
- Abort the persist when the component unmounts (AbortController) to avoid a stale-session write.
Example fix
// before
await chatStore.updateSession(sessionId, (session) => {
if (!session) throw new Error('Session not found')
return { ...session, settings: { ... } }
})
// after — tolerate a missing session (deleted between read and write)
await chatStore.updateSession(sessionId, (session) => {
if (!session) return session // no-op; session was removed
return { ...session, settings: { ... } }
}) Defensive patterns
Strategy: validation
Validate before calling
// Check the session exists before persisting options.
function sessionExists(chatStore: any, sessionId: string): boolean {
return !!chatStore.getSession?.(sessionId)
}
if (sessionId && !sessionExists(chatStore, sessionId)) return Try / catch
// Prefer making the updater tolerate a missing session, but if throwing is kept:
try {
await persistProviderOptions(sessionId, options)
} catch (e) {
if (e instanceof Error && /Session not found/i.test(e.message)) {
// session was deleted concurrently; swallow
return
}
throw e
} Prevention
- Make the updateSession callback return the session unchanged when it is null instead of throwing.
- Abort in-flight persists when the component unmounts or the active session changes.
- Read sessionId from a ref, not a stale closure, to avoid writing to a swapped session.
When it happens
Trigger: persistProviderOptions(sessionId, options) is called with a sessionId that chatStore.updateSession's callback receives as undefined. Happens when the user navigates away or deletes the session between the reasoning-level change and the persist call, or when currentSessionId is read from a stale closure.
Common situations: User changes reasoning level then immediately deletes/switches the session; the component is unmounted mid-async; a race between session creation and the first options persist. The hook guards new sessions via draftByModel but existing sessions hit this path.
Related errors
- Session is missing or invalid
- Invalid session entry: ${entry.path}
- Session was not staged: ${descriptor.path}
- Session id does not match manifest: ${descriptor.path}
- OAuth credential missing for provider: ${chatboxProviderId}
AI-assisted analysis of chatboxai/chatbox@81571269ad (2026-08-12).
Data as JSON: /api/errors/e49c316f5252f17f.
Report an issue: GitHub.