koala73/worldmonitor · error · Error

[_recordPoolFilterStats] no run ${args.runId}

Error message

[_recordPoolFilterStats] no run ${args.runId}

What it means

Thrown by the _recordPoolFilterStats internal mutation when no waveRuns row matches the provided runId via the by_runId index with .unique(). Per its own docstring, this is NOT a normal recovery scenario — it indicates a logic bug in the caller (pickWaveAction), since the run row is created by _claimWaveRunLease before pool selection begins.

Source

Thrown at convex/broadcast/waveRuns.ts:466

 * them for THIS run's pool selection remains useful even if the lease has
 * since rotated. Throws only if the run row itself is missing (a logic
 * bug in the caller, not a normal recovery scenario).
 */
export const _recordPoolFilterStats = internalMutation({
  args: {
    runId: v.string(),
    excludeNonEnglish: v.boolean(),
    eligiblePoolCount: v.number(),
    excludedCount: v.number(),
    excludedLocaleCounts: v.record(v.string(), v.number()),
  },
  handler: async (ctx, args) => {
    const run = await ctx.db
      .query("waveRuns")
      .withIndex("by_runId", (q) => q.eq("runId", args.runId))
      .unique();
    if (!run) {
      throw new Error(`[_recordPoolFilterStats] no run ${args.runId}`);
    }
    await ctx.db.patch(run._id, {
      excludeNonEnglish: args.excludeNonEnglish,
      eligiblePoolCount: args.eligiblePoolCount,
      excludedCount: args.excludedCount,
      excludedLocaleCounts: args.excludedLocaleCounts,
      updatedAt: Date.now(),
    });
    return { ok: true as const };
  },
});

// ───────────────────────────────────────────────────────────────────────────
// Pick phase
// ───────────────────────────────────────────────────────────────────────────

/**
 * Acquire the wave-run lease atomically. Refuses if:

View on GitHub (pinned to ffec79ac33)

Solutions

  1. Trace the runId in the calling action (pickWaveAction) back to the value returned by _claimWaveRunLease — they must be identical.
  2. Check whether discardWaveRun or a manual DB delete removed the row mid-flight; if so, this throw is benign and the run should be treated as cancelled.
  3. If calling from a test, first insert a waveRuns row with that runId, or call through _claimWaveRunLease to create one.
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: pickWaveAction calls runMutation('_recordPoolFilterStats', {runId}) with a runId that was never claimed, was already discarded via discardWaveRun, or has a typo/transcription error. A race where the run was force-deleted between lease acquisition and stat recording.

Common situations: A developer modifies pickWaveAction and passes the wrong runId variable. The operator ran discardWaveRun while pickWaveAction was still executing. A test invokes _recordPoolFilterStats directly with a fabricated runId.

Related errors


AI-assisted analysis of koala73/worldmonitor@ffec79ac33 (2026-08-12). Data as JSON: /api/errors/5643b86c7f3a237b. Report an issue: GitHub.