remotion-dev/remotion · error · Error

Canvas capture chunk ${index + 1} is missing.

Error message

Canvas capture chunk ${index + 1} is missing.

What it means

While streaming chunks, the receiver loops `metadata.chunks` times, reads each chunk key via `getChunkKey(id, index)`, and requires the stored value to be a string. If a chunk is absent or not a string, it throws with the 1-based index. Each successfully posted chunk is removed from storage, so this is also raised if a chunk was already consumed or evicted.

Source

Thrown at packages/canvas-capture-extension/src/receiver.ts:62

	}

	window.postMessage(
		{
			type: `${MESSAGE_PREFIX}-start`,
			captureId: id,
			filename: metadata.filename,
			mimeType: metadata.mimeType,
			chunks: metadata.chunks,
		},
		window.location.origin,
	);

	for (let index = 0; index < metadata.chunks; index++) {
		const key = getChunkKey(id, index);
		const storedChunk = await chrome.storage.local.get(key);
		const chunk = storedChunk[key];
		if (typeof chunk !== 'string') {
			throw new Error(`Canvas capture chunk ${index + 1} is missing.`);
		}

		window.postMessage(
			{
				type: `${MESSAGE_PREFIX}-chunk`,
				captureId: id,
				index,
				data: chunk,
			},
			window.location.origin,
		);
		await chrome.storage.local.remove(key);
	}

	window.postMessage(
		{type: `${MESSAGE_PREFIX}-complete`, captureId: id},
		window.location.origin,
	);

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Request each capture id only once — chunks are deleted after being posted.
  2. Ensure storage has enough quota for all chunks before starting a large capture.
  3. Do not run two receivers for the same capture id concurrently.
  4. Re-record the capture if chunks were partially lost.
Defensive patterns

Strategy: validation

Validate before calling

async function allChunksPresent(id: string, chunks: number): Promise<boolean> {
  for (let i = 0; i < chunks; i++) {
    const key = `capture:${id}:chunk:${i}`;
    const v = (await chrome.storage.local.get(key))[key];
    if (typeof v !== 'string') return false;
  }
  return true;
}

Try / catch

try {
  await receiver.stream(id);
} catch (e) {
  if (e instanceof Error && /chunk .* is missing/.test(e.message)) {
    // chunks are consumed on read; do not retry the same id.
    await reRecord();
  }
  throw e;
}

Prevention

When it happens

Trigger: Requesting the same capture twice (first request removes chunks, second finds them missing); chrome.storage.local evicted individual chunks under quota; a chunk write was interrupted so it never persisted; metadata.chunks overstates the actual number of stored chunks.

Common situations: Replaying a capture after partial consumption; storage pressure evicting entries mid-stream; extension or browser closed mid-write; concurrent receivers consuming the same id.

Related errors


AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12). Data as JSON: /api/errors/3fea95f581dbc2a0. Report an issue: GitHub.