Repository navigation
Description
Existing documentation URL(s)
What changes are you suggesting?
Use one sampling index in the queue consumer's writeDataPoint() call. Keep category and priority in the existing blobs array so readers can still group and filter by either. With the Analytics Engine binding configured, a successfully processed support message should record its metric and reach message.ack().
Additional information
Summary
The example passes two sampling indexes with each metric. Analytics Engine accepts at most one. The example sends a support confirmation and writes the completed status before the metrics call. If that call throws, the catch block requests a retry, and a redelivered job can repeat those effects.
Steps to reproduce
Save the published example source as email-storage.mdx and save the script below alongside it as probe.mjs. Run node probe.mjs. The script extracts the queue example, removes its two imports used by the uncalled inbound handler, and invokes the queue consumer with a synthetic stored support message. All bindings are local stubs.
Local reproduction script
import { readFileSync, writeFileSync } from "node:fs";
const mdx = readFileSync("email-storage.mdx", "utf8");
const queueSection = mdx.split("## Queue-based processing", 2)[1];
const snippet = queueSection.match(/```typescript\n([\s\S]*?)\n```/)[1];
writeFileSync("email-storage.ts", snippet.replace(/^import .*\n/gm, ""));
const { default: worker } = await import("./email-storage.ts");
const body = {
emailId: "email:test",
from: "sender@example.com",
to: "support@example.com",
subject: "Help",
category: "support",
priority: "normal",
};
async function run(enforceIndexLimit) {
const events = [];
const record = { rawContent: "Please help.", size: 12, status: "queued" };
const env = {
EMAIL: {
async send() { events.push("send"); },
},
EMAIL_STORAGE: {
async get() { return JSON.stringify(record); },
async put(_key, value) {
Object.assign(record, JSON.parse(value));
events.push("store:" + record.status);
},
},
EMAIL_ANALYTICS: {
writeDataPoint({ indexes }) {
events.push("indexes:" + indexes.join(","));
if (enforceIndexLimit && indexes.length > 1) {
throw new TypeError("writeDataPoint(): Maximum of 1 indexes supported.");
}
},
},
};
const message = {
body,
ack() { events.push("ack"); },
retry() { events.push("retry"); },
};
await worker.queue({ messages: [message] }, env);
if (enforceIndexLimit) {
events.push("redelivery");
await worker.queue({ messages: [message] }, env);
}
console.log(enforceIndexLimit ? "limit" : "capture", events.join(" | "));
}
await run(false);
await run(true);Expected behavior
The consumer writes a data point with a supported index count and acknowledges the job. Category and priority remain available as dimensions.
Actual behavior
The capture stub received category:support and priority:normal in the same indexes array. The stub that enforces the documented limit recorded send | store:completed | indexes:category:support,priority:normal | retry. A simulated redelivery repeated that sequence. The fixture did not use hosted Analytics Engine or send mail.
Evidence
- Expected source: Workers Analytics Engine limits specifies one index per call. Write data points describes grouping and filtering on blobs and says points with multiple indexes are not recorded.
- Failure source: The queue consumer on the linked Email Service page writes both indexes after storing the completed status. The workerd release test expects a synchronous
TypeErrorfor two indexes. - Evidence provenance: observed
- Local verification: reproduced
- Reproduction completeness: complete
Restoration check
Process one synthetic support job with the revised example and Analytics Engine bound. Confirm that the metric is recorded with category and priority available to query. Confirm that the consumer acknowledges the message without retrying on the index limit.
Runtime or environment
The current Cloudflare Developer Docs production source and served page were checked. The fixture used Node.js v26.13.1 and local binding stubs. The exception behavior comes from the published workerd test.
Triage assessment
- Impact level: P2
- Assessment status: supported
- Impact basis: Users who configure the analytics binding lose the intended metric. In a runtime that throws for multiple indexes, the queue example requests a retry after processing has already sent a support confirmation.
- Workaround status: unverified
- Workaround basis: Omitting the binding bypasses the error and also removes metrics. A configuration-only workaround that preserves metrics was not verified.
Activity