Repository navigation
Conversation
[ci skip]
Added message byte estimation and batching logic to handle message limits. Assisted-By: codex-5.6-sol
✅ Deploy Preview for fedify-json-schema ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Code Review
This pull request bumps the version of several packages to 2.0.23 and updates the WorkersMessageQueue implementation in @fedify/cfworkers to batch messages in enqueueMany based on message count and estimated byte size limits. Feedback was provided regarding a redundant check for undefined on the result of JSON.stringify(body), as it is called on an object literal and will never return undefined.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| const serialized = JSON.stringify(body); | ||
|
|
||
| if (serialized === undefined) { | ||
| throw new TypeError("Queue message must be JSON-serializable."); | ||
| } | ||
|
|
||
| return utf8Encoder.encode(serialized).byteLength + | ||
| ESTIMATED_METADATA_BYTES_PER_MESSAGE; |
There was a problem hiding this comment.
Since body is constructed as an object literal { __fedify_ordering_key__, __fedify_payload__ }, JSON.stringify(body) will never return undefined (it would return "{}" even if both properties were undefined). Therefore, the check for serialized === undefined is redundant and can be safely removed to simplify the code.
const serialized = JSON.stringify(body);
return utf8Encoder.encode(serialized).byteLength +
ESTIMATED_METADATA_BYTES_PER_MESSAGE;|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (54)
📝 WalkthroughWalkthroughCloudflare Workers queue fan-out now splits messages into size- and count-limited batches. The changelog and package manifests are updated for version 2.0.23. ChangesCloudflare Queue batching
Release metadata
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested labels: Suggested reviewers: ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Fixes Cloudflare Workers Queues sendBatch() limit violations in @fedify/cfworkers by estimating message payload sizes and splitting enqueueMany() into multiple batches, addressing issue #958. This PR also bumps the monorepo package versions to 2.0.23 and introduces a new CHANGES.md section for that version.
Changes:
- Add byte-size estimation + batching logic to
WorkersMessageQueue.enqueueMany()to stay under Cloudflare Queues batch constraints. - Bump multiple packages’ versions from
2.0.22to2.0.23. - Add a new
CHANGES.mdsection for version2.0.23.
Reviewed changes
Copilot reviewed 54 out of 54 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| CHANGES.md | Adds a new 2.0.23 section stub. |
| packages/amqp/deno.json | Bumps version to 2.0.23. |
| packages/amqp/package.json | Bumps version to 2.0.23. |
| packages/cfworkers/deno.json | Bumps version to 2.0.23. |
| packages/cfworkers/package.json | Bumps version to 2.0.23. |
| packages/cfworkers/src/mod.ts | Implements size estimation + batch splitting for enqueueMany(). |
| packages/cli/deno.json | Bumps version to 2.0.23. |
| packages/cli/package.json | Bumps version to 2.0.23. |
| packages/create/package.json | Bumps version to 2.0.23. |
| packages/debugger/deno.json | Bumps version to 2.0.23. |
| packages/debugger/package.json | Bumps version to 2.0.23. |
| packages/denokv/deno.json | Bumps version to 2.0.23. |
| packages/elysia/deno.json | Bumps version to 2.0.23. |
| packages/elysia/package.json | Bumps version to 2.0.23. |
| packages/express/deno.json | Bumps version to 2.0.23. |
| packages/express/package.json | Bumps version to 2.0.23. |
| packages/fastify/deno.json | Bumps version to 2.0.23. |
| packages/fastify/package.json | Bumps version to 2.0.23. |
| packages/fedify/deno.json | Bumps version to 2.0.23. |
| packages/fedify/package.json | Bumps version to 2.0.23. |
| packages/fixture/deno.json | Bumps version to 2.0.23. |
| packages/fresh/deno.json | Bumps version to 2.0.23. |
| packages/h3/deno.json | Bumps version to 2.0.23. |
| packages/h3/package.json | Bumps version to 2.0.23. |
| packages/hono/deno.json | Bumps version to 2.0.23. |
| packages/hono/package.json | Bumps version to 2.0.23. |
| packages/init/deno.json | Bumps version to 2.0.23. |
| packages/init/package.json | Bumps version to 2.0.23. |
| packages/koa/deno.json | Bumps version to 2.0.23. |
| packages/koa/package.json | Bumps version to 2.0.23. |
| packages/lint/deno.json | Bumps version to 2.0.23. |
| packages/lint/package.json | Bumps version to 2.0.23. |
| packages/nestjs/package.json | Bumps version to 2.0.23. |
| packages/next/package.json | Bumps version to 2.0.23. |
| packages/postgres/deno.json | Bumps version to 2.0.23. |
| packages/postgres/package.json | Bumps version to 2.0.23. |
| packages/redis/deno.json | Bumps version to 2.0.23. |
| packages/redis/package.json | Bumps version to 2.0.23. |
| packages/relay/deno.json | Bumps version to 2.0.23. |
| packages/relay/package.json | Bumps version to 2.0.23. |
| packages/sqlite/deno.json | Bumps version to 2.0.23. |
| packages/sqlite/package.json | Bumps version to 2.0.23. |
| packages/sveltekit/deno.json | Bumps version to 2.0.23. |
| packages/sveltekit/package.json | Bumps version to 2.0.23. |
| packages/testing/deno.json | Bumps version to 2.0.23. |
| packages/testing/package.json | Bumps version to 2.0.23. |
| packages/vocab/deno.json | Bumps version to 2.0.23. |
| packages/vocab/package.json | Bumps version to 2.0.23. |
| packages/vocab-runtime/deno.json | Bumps version to 2.0.23. |
| packages/vocab-runtime/package.json | Bumps version to 2.0.23. |
| packages/vocab-tools/deno.json | Bumps version to 2.0.23. |
| packages/vocab-tools/package.json | Bumps version to 2.0.23. |
| packages/webfinger/deno.json | Bumps version to 2.0.23. |
| packages/webfinger/package.json | Bumps version to 2.0.23. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const messageBytes = estimateMessageBytes(body); | ||
| const exceedsBatchLimit = batch.length >= MAX_BATCH_MESSAGES || | ||
| estimatedBatchBytes + messageBytes > MAX_ESTIMATED_BATCH_BYTES; | ||
|
|
||
| if (batch.length > 0 && exceedsBatchLimit) { |
| Version 2.0.23 | ||
| -------------- | ||
|
|
||
| To be released. | ||
|
|
||
|
|
| const estimateMessageBytes = (body: WrappedMessage): number => { | ||
| const serialized = JSON.stringify(body); | ||
|
|
||
| if (serialized === undefined) { | ||
| throw new TypeError("Queue message must be JSON-serializable."); | ||
| } | ||
|
|
||
| return utf8Encoder.encode(serialized).byteLength + | ||
| ESTIMATED_METADATA_BYTES_PER_MESSAGE; | ||
| }; |
Summary
Fixed
WorkersMessageQueue.enqueueMany()failing when the given messages exceeded Cloudflare Queues' batch limits of 100 messages or 256 KB per batch.Assisted-by: chatgpt codex-5.6-sol
Changes
sendBatch()calls