PRO

Vercel Queue Consumer Groups

A @vercel/queue producer and consumer built around the fact that Vercel Queues inverts the publish/consume race: the docs state the publish acknowledgment and consumer notification happen simultaneously, so a consumer may begin processing a message before send() returns and the near-universal send-then-write idiom is a guaranteed intermittent 404. The producer commits first, then publishes with an idempotencyKey and a deliberately short retentionSeconds, and documents the hazard at the exact line where it bites. The consumer is one handler in one consumer group, because multiple route files on the same topic create separate groups that each receive a copy of every message, which is fan-out dressed up as scaling. Since there is no dead-letter queue, it implements a real poison-message policy: permanent versus transient classification, a deliveryCount cap, and acknowledge-with-record inside the handler where the write can be awaited. Also covers deployment-ID topic partitioning, the 300s SDK versus 60s raw API visibility timeout split, and the absence of FIFO ordering.

Install
npx shadcn@latest add https://ui.aryank.space/r/vercel-queue-consumer-groups.json

Installs from ui.aryank.space. To add it by hand, copy the files in Files below, or register the @compronents namespace via the docs.

Visualization
producer order
send()
Promise<{ messageId: string }>
consumer
unknown
db insert
Promise<Order>
await queue.send(msg); await db.insert(order) // consumer ran between

Vercel Queues acks the publish and notifies the consumer at the same moment, so the consumer can start BEFORE send() returns. Here it does: it looks up the order row the producer has not written yet, finds nothing, and fails. The near-universal send-then-write idiom is a guaranteed intermittent bug on this queue.

Files

Dependencies