Skip to content

Test Workers queue wrapper round trips - #1240

Merged
dahlia merged 1 commit into
fedify-dev:mainfrom
Lumia1108:issue-1049-cfworkers-round-trip
Oct 5, 2026
Merged

dahlia merged 1 commit into
fedify-dev:mainfrom
Lumia1108:issue-1049-cfworkers-round-trip

Conversation

@Lumia1108

@Lumia1108 Lumia1108 commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

The existing queue tests check producers and consumers separately using manually constructed message wrappers. They do not verify that messages produced by enqueue() and enqueueMany() can be consumed by processMessage().

This PR adds two round-trip tests using the existing vi.spyOn(env.Q1, ...) pattern. Each test captures the message passed to send() or an item's body passed to sendBatch(), then passes it to processMessage(). The assertions verify payload preservation and ordering-key preservation through KV lock acquisition and release.

Closes #1049.

Testing

The following checks passed locally:

  • mise run check-each cfworkers
  • mise exec --no-deps -- pnpm --filter @fedify/cfworkers test: 3 test files and 50 tests passed.

mise run test-each cfworkers failed during Vitest startup in the Deno task stage with Could not find referrer npm package. I used the package's test script through pnpm and Node.js to run the Workers tests.

AI assistance

I used Codex with gpt-5.6-sol and gpt-6-astra for test-runner diagnosis, final diff review, understanding the relevant code, and improving my draft implementation. I reviewed and finalized the implementation and verified the tests locally.

Pass messages captured from send() and sendBatch() into
processMessage() to verify payload and ordering-key preservation.

Codex assisted with test-runner diagnosis, final diff review,
understanding the relevant code, and improving my draft implementation.
I reviewed and finalized the implementation and verified the tests
locally.

fedify-dev#1049

Changelog: none
Assisted-by: Codex:gpt-5.6-sol
Assisted-by: Codex:gpt-6-astra
@netlify

netlify Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for fedify-json-schema canceled.

Name Link
🔨 Latest commit f957831
🔍 Latest deploy log https://app.netlify.com/projects/fedify-json-schema/deploys/6ac38f1900226a000803740c

@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 90a2afd0-e98d-4254-a8ee-8104d15bc91c
📥 Commits

Reviewing files that changed from the base of the PR and between 3a7ba49 and f957831.

📒 Files selected for processing (1)
  • packages/cfworkers/test/mq.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The queue tests now pass messages from single and batch enqueueing to processMessage(). They check payloads and ordering-lock acquisition and release.

Changes

Queue message round trips

Layer / File(s) Summary
Single and batch message round trips
packages/cfworkers/test/mq.test.ts
Tests cover processing an enqueued message and the first message from an enqueued batch. They check payloads, ordering-lock key access with a 60-second TTL, and lock deletion when release is called.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Merge Risk: ⚪ Minimal · up to f9578

The new tests cover single and batch queue-message round trips; the change is ready to merge after normal checks.

Architecture Summary

Architecture risk: 🔵 Low · up to f9578

The change affects 1 system.

Changed systems: packages/cfworkers

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — packages/cfworkers (library) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in packages/cfworkers/test/mq.test.ts: Adds a test that enqueues a payload with an ordering key, processes the sent message, and checks the returned payload, lock acquisition under the prefixed KV key with a 60-second TTL, and lock deletion when release is called.
  • observed — Modified behavior in packages/cfworkers/test/mq.test.ts: Adds the equivalent round-trip test for the first message in an enqueued batch, checking its payload and ordering lock acquisition and release.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Issue [#1049] requires round-trip tests for enqueue() and enqueueMany() in packages/cfworkers/test/mq.test.ts, using vi.spyOn(env.Q1, ...). The added tests capture the send() argument and a …
Out of Scope Changes check ✅ Passed The changes add only the two queue-wrapper round-trip tests required by issue [#1049]. The KV assertions support verification that the ordering key survives processing. No unrelated changes appear in …
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Title check ✅ Passed The title clearly summarizes the addition of round-trip tests for the Workers queue wrapper.
Description check ✅ Passed The description explains the round-trip tests, their assertions, and the reported test results.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.
see 315 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dahlia dahlia self-assigned this Oct 5, 2026
@dahlia dahlia added component/mq Message queue related runtime/cfworkers Cloudflare Workers runtime related labels Oct 5, 2026
@dahlia dahlia added this to the Fedify 2.5 milestone Oct 5, 2026

@dahlia dahlia left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job! Thanks!

@dahlia
dahlia merged commit d4e3f91 into fedify-dev:main Oct 5, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/mq Message queue related runtime/cfworkers Cloudflare Workers runtime related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test the queue message wrapper round trip in @fedify/cfworkers

2 participants