immich-app/immich · error · Error

Task with id not found

Error message

Task with id ${id} not found

What it means

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.

Solutions

  1. Retain the Task object or id returned by push() and only call getTask with that exact, live id.
  2. Check whether the task was already awaited/completed before calling getTask; use the awaited result instead.
  3. Re-run the CLI without custom concurrency/retry overrides to rule out the retry-path bug.
  4. If it occurs inside the stock CLI, report it with the command line used; it is an internal bug.

Example fix

// before
const task = queue.getTask(id);
// after
const task = queue.getTask?.(id) ?? undefined;
if (!task) { console.warn(`task ${id} no longer exists`); return; }
Defensive patterns

Strategy: try-catch

Validate before calling

// only look up ids returned by push()
const id = queue.push(job); // keep this handle

Try / catch

try {
  const task = queue.getTask(id);
} catch (err) {
  if (String(err).includes('Task with id')) {
    console.warn(`task ${id} already completed/removed`);
    return;
  }
  throw err;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of immich-app/immich@e55ac299a4 (2026-09-15). Data as JSON: /api/errors/175a5cdcc30ba734. Report an issue: GitHub.

Appendix: source

Thrown at packages/cli/src/queue.ts:62

   * @param worker - The worker function that processes the task.
   * @param options - The queue options.
   */
  constructor(worker: (data: T) => Promise<R>, options?: QueueOptions) {
    this.options = { ...defaultQueueOptions, ...options };
    this.worker = worker;
    this.store = new Map<string, Task<T, R>>();
    this.queue = this.buildQueue();
  }

  get tasks(): Task<T, R>[] {
    const tasks: Task<T, R>[] = this.store.values().toArray();
    return tasks;
  }

  getTask(id: string): Task<T, R> {
    const task = this.store.get(id);
    if (!task) {
      throw new Error(`Task with id ${id} not found`);
    }
    return task;
  }

  /**
   * Wait for the queue to be empty.
   * @returns Promise<void> - The returned Promise will be resolved when all tasks in the queue have been processed by a worker.
   * This promise could be ignored as it will not lead to a `unhandledRejection`.
   */
  drained(): Promise<void> {
    return this.queue.drained();
  }

  /**
   * Add a task at the end of the queue.
   * @see {@link https://www.npmjs.com/package/fastq}
   * @param data
   * @returns Promise<void> - A Promise that will be fulfilled (rejected) when the task is completed successfully (unsuccessfully).

View on GitHub (pinned to e55ac299a4)