thedotmack/claude-mem · warning

Conflict

Conflict

Error message

Generation job is currently processing; cancel or wait for completion before retrying

What it means

A 409 Conflict returned when an operator attempts to retry a generation job whose status is 'processing'. The library refuses because the in-flight worker must be allowed to finish or fail through its normal lifecycle; racing it would double-run the provider.

Solutions

  1. Poll the job status until it transitions to 'completed', 'failed', or 'cancelled' before retrying.
  2. If the job is genuinely hung, cancel it first (cancel endpoint), then retry.
  3. Add a client-side guard that only issues retry when the last-known status is retryable.
  4. Check worker health/logs — long processing may be normal for large payloads.

Example fix

// before
await fetch(`/v1/generation-jobs/${id}/retry`, { method: 'POST' });
// after
const job = await (await fetch(`/v1/generation-jobs/${id}`)).json();
if (job.status === 'processing') await cancelJob(id); // or wait
await fetch(`/v1/generation-jobs/${id}/retry`, { method: 'POST' });
Defensive patterns

Strategy: validation

Validate before calling

const job = await getGenerationJob(id);
if (job.status === 'processing') throw new Error('job still processing — wait or cancel before retry');

Type guard

function isRetryable(status: string): boolean {
  return ['failed', 'cancelled'].includes(status);
}

Try / catch

const res = await retryGenerationJob(id);
if (res.status === 409) {
  const body = await res.json();
  if (body.message.includes('processing')) await pollUntilTerminal(id, thenRetry);
}

Prevention

When it happens

Trigger: POST to the generation-job retry route for a job whose current.status === 'processing' — i.e. a worker is actively executing the job at the moment of the retry request.

Common situations: Operator sees a stuck-looking job and retries while the worker is actually still running; double-clicking a retry button in a dashboard; automation that retries without checking status first.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of thedotmack/claude-mem@d8bc9755e7 (2026-09-17). Data as JSON: /api/errors/563aa2d43a0b71fe. Report an issue: GitHub.

Appendix: source

Thrown at src/server/routes/v1/ServerV1PostgresRoutes.ts:1525

      load: (projectId) => repo.getByIdForScope({ id, projectId, teamId }),
    });
    if (!current) return null;

    // Idempotent fast-path: already queued -> emit audit only, no DB writes.
    if (current.status === 'queued') {
      await this.auditWrite(req, 'generation_job.retried_by_operator', current.id, current.projectId, {
        outcome: 'noop_already_queued',
        currentAttempts: current.attempts,
        requestId: req.requestId ?? null,
      });
      return { job: current, retriedCount: extractRetriedCount(current.payload), alreadyQueued: true };
    }

    if (current.status === 'processing') {
      // Refuse retry on in-flight jobs — the running worker MUST be allowed
      // to finish or fail through its normal lifecycle. Operator can wait
      // or cancel, then retry.
      res.status(409).json({
        error: 'Conflict',
        message: 'Generation job is currently processing; cancel or wait for completion before retrying',
      });
      return null;
    }

    if (current.status === 'completed') {
      // Refuse retry on already-completed jobs. The deduplication index on
      // observations (generation_key = job_id + index + content) does NOT
      // protect against re-running the provider, because LLM output is
      // non-deterministic and the second run almost always produces a
      // different content string. Replaying would persist a parallel set
      // of observations attributed to the same generation_job_id.
      // cancelGenerationJob applies the same 409 guard for the same reason.
      res.status(409).json({
        error: 'Conflict',
        message: 'Generation job already completed; retrying would duplicate observations',
      });

View on GitHub (pinned to d8bc9755e7)