can1357/oh-my-pi · error

Pending daemon completion is not an event

Error message

Pending daemon completion is not an event

What it means

When the broker decodes a pendingCompletions snapshot from the wire, each entry must be a daemon *event* message. parseDaemonWireMessage may return other message kinds (e.g. results or requests); if a pending completion entry parses to a message without an 'event' field, the broker throws this error to fail fast on malformed wire data.

Source

Thrown at packages/coding-agent/src/launch/broker.ts:1297

					generation: 0,
					stopRequested: !detached || snapshot.state === "stopping",
					logReady: detached && (!spec.ready?.log || snapshot.state === "ready"),
					portReady: detached && (spec.ready?.port === undefined || snapshot.state === "ready"),
					readinessBuffer: "",
					outputOffset: detached ? snapshot.outputBytes : 0,
					readyPattern: spec.ready?.log ? new RegExp(spec.ready.log, "u") : undefined,
					consecutiveFailures: 0,
					persistQueue: Promise.resolve(),
					completionCapable: "completionEvents" in decoded && decoded.completionEvents === true,
					completionSubscriptionId:
						"completionSubscriptionId" in decoded && typeof decoded.completionSubscriptionId === "string"
							? decoded.completionSubscriptionId
							: undefined,
					pendingCompletions: (() => {
						if ("pendingCompletions" in decoded && Array.isArray(decoded.pendingCompletions)) {
							return decoded.pendingCompletions.map(value => {
								const message = parseDaemonWireMessage(value);
								if (!("event" in message)) throw new Error("Pending daemon completion is not an event");
								return message;
							});
						}
						const pendingSnapshot =
							"pendingCompletion" in decoded
								? parseDaemonSnapshot(decoded.pendingCompletion)
								: "completionPending" in decoded && decoded.completionPending === true
									? { ...snapshot }
									: undefined;
						return pendingSnapshot
							? [
									{
										event: "daemon-completed",
										completionId: crypto.randomUUID(),
										owner: pendingSnapshot.owner ?? snapshot.owner ?? "",
										daemon: pendingSnapshot,
									},
								]

View on GitHub (pinned to 9690622007)

Solutions

  1. Upgrade both broker and client to matching versions so pendingCompletions always carries event messages
  2. Delete stale runtime state under the daemon runtime dir and restart the broker
  3. Inspect the serialized pendingCompletions payload to find the non-event entry and fix the producer

Example fix

// before
const message = parseDaemonWireMessage(value); // may be any kind
return message;
// after
const message = parseDaemonWireMessage(value);
if (!("event" in message)) throw new Error("Pending daemon completion is not an event");
return message;
Defensive patterns

Strategy: validation

Validate before calling

if (!Array.isArray(decoded.pendingCompletions)) throw new Error('pendingCompletions must be an array');
for (const value of decoded.pendingCompletions) {
  const msg = parseDaemonWireMessage(value);
  if (!("event" in msg)) throw new Error('non-event pending completion: ' + JSON.stringify(value));
}

Type guard

function isDaemonEventMessage(m: ReturnType<typeof parseDaemonWireMessage>): m is DaemonEventMessage {
  return "event" in m;
}

Try / catch

try {
  const completions = decoded.pendingCompletions.map(v => parseDaemonWireMessage(v));
} catch (err) {
  logger.warn('Malformed pendingCompletions, dropping snapshot', { error: err.message });
}

Prevention

When it happens

Trigger: A daemon wire message inside the pendingCompletions array of a broker handshake/snapshot payload lacks an 'event' discriminator — i.e. a non-event message was queued or serialized as a pending completion.

Common situations: Version mismatch between broker and client where the pendingCompletions serialization changed; corrupted or hand-edited runtime state; a bug in code that enqueues results into pendingCompletions.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/ceb15e186f191b84. Report an issue: GitHub.