{"record":{"id":"afc73d9b4ffe3bf2","repo":"stablyai/orca","slug":"download-session-not-found","errorCode":null,"errorMessage":"Download session not found","messagePattern":"Download session not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/main/ipc/filesystem.ts","lineNumber":785,"sourceCode":"        return { canceled: false, transferId, destinationPath }\n      } catch (error) {\n        await cleanupLocalTransferPath(tempPath)\n        throw error\n      }\n    }\n  )\n\n  ipcMain.handle(\n    'fs:appendDownloadedFileChunk',\n    async (\n      _event,\n      args: { transferId?: string; contentBase64?: string }\n    ): Promise<{ ok: true }> => {\n      const transferId = validateRequiredString(args?.transferId, 'transferId')\n      const contentBase64 = validateRequiredString(args?.contentBase64, 'contentBase64')\n      const session = downloadSessions.get(transferId)\n      if (!session) {\n        throw new Error('Download session not found')\n      }\n      await session.handle.writeFile(Buffer.from(contentBase64, 'base64'))\n      return { ok: true }\n    }\n  )\n\n  ipcMain.handle(\n    'fs:finishDownloadedFile',\n    async (\n      _event,\n      args: { transferId?: string }\n    ): Promise<{ canceled: false; destinationPath: string }> => {\n      const transferId = validateRequiredString(args?.transferId, 'transferId')\n      const session = await closeDownloadSession(transferId, false)\n      if (!session) {\n        throw new Error('Download session not found')\n      }\n      let promoted = false","sourceCodeStart":767,"sourceCodeEnd":803,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/ipc/filesystem.ts#L767-L803","documentation":"Thrown by 'fs:appendDownloadedFileChunk' (src/main/ipc/filesystem.ts:785) when downloadSessions.get(transferId) returns undefined. Download sessions live in an in-memory Map keyed by transferId; they are created by fs:startDownloadedFile and removed by fs:finishDownloadedFile, fs:cancelDownloadedFile, a 30-minute TTL cleanup timer (DOWNLOAD_SESSION_TTL_MS), or cleanupDownloadSessionsForSender when the owning webContents is destroyed.","triggerScenarios":"An append chunk arriving for a transferId whose session was already closed: finish/cancel ran first, the 30-min TTL timer fired, the sender window was destroyed/reloaded, or the transferId was never started or belongs to a different sender.","commonSituations":"Very large or paused transfers exceeding the 30-minute TTL; renderer resuming a download after the window closed and reopened; a double-finish/cancel race; stale transferId held across an SSH reconnect that tore down app state.","solutions":["Restart the download via fs:startDownloadedFile to obtain a fresh transferId, then re-stream the file.","Ensure the full append sequence completes within the 30-minute TTL and before the owning window closes.","Confirm the transferId matches the most recent start response and that the same webContents issued it."],"exampleFix":"// before: appending after the session was finished/expired\nawait invoke('fs:appendDownloadedFileChunk', { transferId: staleId, contentBase64 })\n\n// after: restart on session-not-found, then continue\ntry { await invoke('fs:appendDownloadedFileChunk', { transferId, contentBase64 }) }\ncatch (e) {\n  if (/session not found/.test(e.message)) {\n    const r = await invoke('fs:startDownloadedFile', { suggestedName })\n    transferId = r.transferId\n  } else throw e\n}","handlingStrategy":"validation","validationCode":"// Track transfer lifecycle in the renderer; treat append as valid only while 'active'.\nfunction canAppend(t: { id: string; state: 'active' | 'done' | 'canceled' }): boolean {\n  return t.state === 'active'\n}","typeGuard":null,"tryCatchPattern":"try {\n  await invoke('fs:appendDownloadedFileChunk', { transferId, contentBase64 })\n} catch (e) {\n  if (e instanceof Error && /session not found/.test(e.message)) {\n    // restart: fs:startDownloadedFile -> new transferId -> re-stream from the beginning\n  } else throw e\n}","preventionTips":["Finish transfers well within the 30-minute TTL.","Cancel (fs:cancelDownloadedFile) on window unload so sessions do not leak.","Do not reuse a transferId across a window reload/reconnect."],"tags":["ipc","download","state","electron","race"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}