koala73/worldmonitor · error · Error

[_markBroadcastCreated] no run ${runId}

Error message

[_markBroadcastCreated] no run ${runId}

What it means

Internal invariant guard in _markBroadcastCreated: no waveRuns row exists for the supplied runId. The broadcastId cannot be recorded because the run record is missing — a caller logic bug, or the run row was deleted while finalize was mid-flight.

Source

Thrown at convex/broadcast/waveRuns.ts:1279

 *
 * Without these guards, two concurrent finalizeWaveAction invocations
 * (e.g. operator-triggered resumeFinalizeWaveRun while the original is
 * mid-flight on a slow Resend response) could both call
 * createProLaunchBroadcast, both call _markBroadcastCreated, and overwrite
 * each other's broadcastId — leading to one of the two created Resend
 * broadcasts being orphaned + duplicate sends downstream.
 */
export const _markBroadcastCreated = internalMutation({
  args: {
    runId: v.string(),
    broadcastId: v.string(),
  },
  handler: async (ctx, { runId, broadcastId }) => {
    const run = await ctx.db
      .query("waveRuns")
      .withIndex("by_runId", (q) => q.eq("runId", runId))
      .unique();
    if (!run) throw new Error(`[_markBroadcastCreated] no run ${runId}`);

    // Idempotent: if already broadcast-created with the SAME broadcastId,
    // treat as no-op success. Different broadcastId = a duplicate Resend
    // broadcast was created — surface as failure so the caller can decide
    // (typically: log, don't proceed to send the new duplicate).
    if (run.status === "broadcast-created") {
      if (run.broadcastId === broadcastId) {
        return { ok: true as const, alreadyMarked: true as const };
      }
      return {
        ok: false as const,
        reason: "duplicate-broadcast-detected" as const,
        existing: run.broadcastId,
      };
    }
    if (run.status !== "pushing") {
      return { ok: false as const, reason: `wrong-status-${run.status}` as const };
    }

View on GitHub (pinned to eeab0a219f)

Solutions

  1. Verify the runId matches the one claimed at pick time
  2. Investigate deletion of the waveRuns row (operator purge, retention job) and reconcile the orphaned Resend broadcast manually
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at convex/broadcast/waveRuns.ts:1279 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of koala73/worldmonitor@eeab0a219f (2026-08-21). Data as JSON: /api/errors/2b34fd774d590c0b. Report an issue: GitHub.