{"record":{"id":"175a5cdcc30ba734","repo":"immich-app/immich","slug":"task-with-id-id-not-found","errorCode":null,"errorMessage":"Task with id ${id} not found","messagePattern":"Task with id (.+?) not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/queue.ts","lineNumber":62,"sourceCode":"   * @param worker - The worker function that processes the task.\n   * @param options - The queue options.\n   */\n  constructor(worker: (data: T) => Promise<R>, options?: QueueOptions) {\n    this.options = { ...defaultQueueOptions, ...options };\n    this.worker = worker;\n    this.store = new Map<string, Task<T, R>>();\n    this.queue = this.buildQueue();\n  }\n\n  get tasks(): Task<T, R>[] {\n    const tasks: Task<T, R>[] = this.store.values().toArray();\n    return tasks;\n  }\n\n  getTask(id: string): Task<T, R> {\n    const task = this.store.get(id);\n    if (!task) {\n      throw new Error(`Task with id ${id} not found`);\n    }\n    return task;\n  }\n\n  /**\n   * Wait for the queue to be empty.\n   * @returns Promise<void> - The returned Promise will be resolved when all tasks in the queue have been processed by a worker.\n   * This promise could be ignored as it will not lead to a `unhandledRejection`.\n   */\n  drained(): Promise<void> {\n    return this.queue.drained();\n  }\n\n  /**\n   * Add a task at the end of the queue.\n   * @see {@link https://www.npmjs.com/package/fastq}\n   * @param data\n   * @returns Promise<void> - A Promise that will be fulfilled (rejected) when the task is completed successfully (unsuccessfully).","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/immich-app/immich/blob/e55ac299a4ec7cb372e35dbf2c6c05ee9ce77f6c/packages/cli/src/queue.ts#L44-L80","documentation":"The Immich CLI's internal Queue stores tasks by a generated id; getTask(id) throws when no task with that id exists in the store. This is an internal invariant violation: callers should only ask for ids returned by queue.push, so the error normally indicates a task was already removed/completed or an id was mistyped by library code.","triggerScenarios":"getTask or the queue's internal bookkeeping (task completion/retry handling) asks for an id that has already been deleted from the store, or code passes an id not originating from push(); can surface under aggressive retry/concurrency settings.","commonSituations":"Hitting it while running `immich upload` with custom concurrency/retry values (a bug interacting with the retry path), or embedding the Immich Queue class in your own tool and looking up an id after the task was resolved.","solutions":["Retain the Task object or id returned by push() and only call getTask with that exact, live id.","Check whether the task was already awaited/completed before calling getTask; use the awaited result instead.","Re-run the CLI without custom concurrency/retry overrides to rule out the retry-path bug.","If it occurs inside the stock CLI, report it with the command line used; it is an internal bug."],"exampleFix":"// before\nconst task = queue.getTask(id);\n// after\nconst task = queue.getTask?.(id) ?? undefined;\nif (!task) { console.warn(`task ${id} no longer exists`); return; }","handlingStrategy":"try-catch","validationCode":"// only look up ids returned by push()\nconst id = queue.push(job); // keep this handle","typeGuard":null,"tryCatchPattern":"try {\n  const task = queue.getTask(id);\n} catch (err) {\n  if (String(err).includes('Task with id')) {\n    console.warn(`task ${id} already completed/removed`);\n    return;\n  }\n  throw err;\n}","preventionTips":["Never construct task ids manually; use the value returned by push()","Consume the task's promise instead of polling via getTask after completion","Avoid stock concurrency/retry overrides unless required"],"tags":["queue","internal-state","concurrency"],"backgroundTag":"entity-not-found","analyzedSha":"e55ac299a4ec7cb372e35dbf2c6c05ee9ce77f6c","analyzedAt":"2026-09-15T07:20:19.675Z","contentChangedAt":"2026-09-15T07:20:19.675Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}