Skip to content

Conversation

@ericallam
Copy link
Member

No description provided.

@changeset-bot
Copy link

changeset-bot bot commented Dec 23, 2025

⚠️ No Changeset found

Latest commit: 073fc1b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 23, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

This change threads a new masterQueueKey through the fair-queue visibility and message-handling paths. VisibilityManager APIs and the internal release/reclaim flows now accept and propagate masterQueueKey so releases, delays, retries, and timed-out reclaim operations update master-queue metadata. The Lua releaseMessage script and its Redis command arity were extended (adds masterQueueKey as a KEY and queueId in ARGV). Several private handlers and tests were updated to pass the new parameter; some error logging calls were reformatted.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Summary of changes

  • VisibilityManager API:

    • VisibilityManager.release signature now includes masterQueueKey: string.
    • reclaimTimedOut getQueueKeys now returns { queueKey, queueItemsKey, masterQueueKey }.
    • Calls to releaseMessage within VisibilityManager now pass masterQueueKey and queueId.
  • Redis/Lua command:

    • releaseMessage Lua script KEYS expanded to include masterQueueKey (5 KEYS total).
    • ARGV extended to include queueId.
    • Script logic updated to update masterQueueKey with the oldest message timestamp when releasing.
    • Redis client/command type declarations updated to reflect the new KEYS/ARGV arity.
  • Fair-queue message handling:

    • Private helpers and handler paths (#releaseMessage, #handleMessageFailure, #processMessage, reclaim/release flows) updated to accept and propagate masterQueueKey for all release/delay/retry operations.
    • Refill and payload-validation failure paths now call visibility.release with masterQueueKey to preserve master-queue alignment.
    • reclaimTimedOut reclaim path now passes masterQueueKey into visibility release calls.
  • Tests:

    • raceConditions.test.ts updated: reclaimTimedOut callback object now includes masterQueueKey: keys.masterQueueKey(0).
  • Misc:

    • Error logging calls reformatted to pass a single object argument in some catch blocks.
    • Minor formatting/argument-order adjustments to accommodate masterQueueKey threading.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning No pull request description was provided by the author, leaving all required sections of the template (Testing, Changelog) completely empty. Add a complete pull request description including Testing steps, Changelog entry, and issue reference to meet repository requirements.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding batch queue back to master queue after visibility timeout, which aligns with the code changes threading masterQueueKey through visibility management.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ea-branch-110

📜 Recent review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b4bb823 and 073fc1b.

📒 Files selected for processing (1)
  • packages/redis-worker/src/fair-queue/visibility.ts
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{ts,tsx}: Use types over interfaces for TypeScript
Avoid using enums; prefer string unions or const objects instead

Files:

  • packages/redis-worker/src/fair-queue/visibility.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use function declarations instead of default exports

Files:

  • packages/redis-worker/src/fair-queue/visibility.ts
**/*.{js,ts,jsx,tsx,json,md,css,scss}

📄 CodeRabbit inference engine (AGENTS.md)

Format code using Prettier

Files:

  • packages/redis-worker/src/fair-queue/visibility.ts
🧬 Code graph analysis (1)
packages/redis-worker/src/fair-queue/visibility.ts (2)
packages/redis-worker/src/fair-queue/keyProducer.ts (3)
  • queueKey (37-39)
  • queueItemsKey (41-43)
  • masterQueueKey (29-31)
packages/redis-worker/src/fair-queue/masterQueue.ts (1)
  • queueId (195-197)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (24)
  • GitHub Check: Cursor Bugbot
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (6, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (5, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (8, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (1, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (7, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (4, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (3, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (2, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (7, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (8, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (6, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (5, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (2, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (3, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (4, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (1, 8)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - pnpm)
  • GitHub Check: units / packages / 🧪 Unit Tests: Packages (1, 1)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - npm)
  • GitHub Check: typecheck / typecheck
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (4)
packages/redis-worker/src/fair-queue/visibility.ts (4)

189-218: LGTM - masterQueueKey propagation looks correct.

The release method signature extension and the updated releaseMessage call properly thread the new masterQueueKey parameter through to the Lua script. The parameter order matches the Lua script's KEYS/ARGV expectations.


235-241: LGTM - Callback type properly extended.

The getQueueKeys callback signature now correctly requires callers to provide masterQueueKey alongside the existing queue keys, ensuring consistency throughout the reclaim flow.


267-282: LGTM - Reclaim flow correctly propagates masterQueueKey.

The destructuring and releaseMessage call properly thread masterQueueKey through the reclaim path, ensuring timed-out messages update the master queue when released.


520-530: LGTM - Type declaration matches implementation.

The releaseMessage interface signature correctly reflects the updated Lua script with 5 KEYS (inflightKey, inflightDataKey, queueKey, queueItemsKey, masterQueueKey) and 4 ARGV parameters (member, messageId, score, queueId).


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 and usage tips.

@vibe-kanban-cloud
Copy link

Review Complete

Your review story is ready!

View Story

Comment !reviewfast on this PR to re-generate the story.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/redis-worker/src/fair-queue/index.ts (1)

1120-1127: Minor refactor: Error logging consolidated to single object parameter.

The error logging call has been reformatted to pass a single structured object parameter rather than multiple string parameters, improving consistency with structured logging practices.

📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d416f34 and b4bb823.

📒 Files selected for processing (3)
  • packages/redis-worker/src/fair-queue/index.ts
  • packages/redis-worker/src/fair-queue/tests/raceConditions.test.ts
  • packages/redis-worker/src/fair-queue/visibility.ts
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{ts,tsx}: Use types over interfaces for TypeScript
Avoid using enums; prefer string unions or const objects instead

Files:

  • packages/redis-worker/src/fair-queue/tests/raceConditions.test.ts
  • packages/redis-worker/src/fair-queue/index.ts
  • packages/redis-worker/src/fair-queue/visibility.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use function declarations instead of default exports

Files:

  • packages/redis-worker/src/fair-queue/tests/raceConditions.test.ts
  • packages/redis-worker/src/fair-queue/index.ts
  • packages/redis-worker/src/fair-queue/visibility.ts
**/*.{test,spec}.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use vitest for all tests in the Trigger.dev repository

Files:

  • packages/redis-worker/src/fair-queue/tests/raceConditions.test.ts
**/*.{js,ts,jsx,tsx,json,md,css,scss}

📄 CodeRabbit inference engine (AGENTS.md)

Format code using Prettier

Files:

  • packages/redis-worker/src/fair-queue/tests/raceConditions.test.ts
  • packages/redis-worker/src/fair-queue/index.ts
  • packages/redis-worker/src/fair-queue/visibility.ts
**/*.test.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.test.{ts,tsx,js,jsx}: Test files should live beside the files under test and use descriptive describe and it blocks
Avoid mocks or stubs in tests; use helpers from @internal/testcontainers when Redis or Postgres are needed
Use vitest for unit tests

Files:

  • packages/redis-worker/src/fair-queue/tests/raceConditions.test.ts
🧬 Code graph analysis (2)
packages/redis-worker/src/fair-queue/tests/raceConditions.test.ts (1)
packages/redis-worker/src/fair-queue/schedulers/drr.ts (1)
  • keys (184-187)
packages/redis-worker/src/fair-queue/visibility.ts (1)
packages/redis-worker/src/fair-queue/keyProducer.ts (3)
  • queueKey (37-39)
  • queueItemsKey (41-43)
  • masterQueueKey (29-31)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (24)
  • GitHub Check: Cursor Bugbot
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (6, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (5, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (7, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (4, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (3, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (8, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (1, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (5, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (2, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (6, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (4, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (1, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (3, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (7, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (8, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (2, 8)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
  • GitHub Check: units / packages / 🧪 Unit Tests: Packages (1, 1)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - npm)
  • GitHub Check: typecheck / typecheck
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - pnpm)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (11)
packages/redis-worker/src/fair-queue/visibility.ts (4)

189-225: LGTM! Master queue key properly threaded through release flow.

The release method signature and implementation correctly add the masterQueueKey parameter and propagate it to the releaseMessage Redis command. The Lua script will now ensure that released messages update the master queue for proper consumer pickup.


235-301: LGTM! Reclaim flow properly updated to include master queue key.

The reclaimTimedOut method signature correctly extends the getQueueKeys callback to return masterQueueKey, and the implementation properly threads it through to the releaseMessage call. This ensures reclaimed messages are correctly tracked in the master queue.


441-477: LGTM! Lua script correctly updates master queue during message release.

The updated releaseMessage Lua script correctly:

  1. Accepts masterQueueKey as the 5th key and queueId in ARGV
  2. Updates the master queue with the message's score, ensuring the queue priority reflects the oldest message timestamp
  3. Maintains atomicity by performing all operations (remove from in-flight, add to queue, update master queue) within the same script

The use of the message score for the master queue entry ensures proper scheduling priority.


516-526: LGTM! TypeScript declaration correctly updated.

The releaseMessage command declaration properly reflects the updated signature with masterQueueKey and queueId parameters, matching the Lua script implementation.

packages/redis-worker/src/fair-queue/tests/raceConditions.test.ts (1)

446-450: LGTM! Test correctly updated for new master queue key requirement.

The test properly supplies masterQueueKey using keys.masterQueueKey(0), which is correct for this single-shard test scenario (shardCount: 1 on line 400). This aligns with the updated reclaimTimedOut signature in visibility.ts.

packages/redis-worker/src/fair-queue/index.ts (6)

818-825: LGTM! Release call correctly updated with master queue key.

The release call after failed concurrency reservation properly includes the masterQueueKey parameter, ensuring the master queue is updated when messages are returned to the queue. This maintains consistency in the two-stage processing flow.


1065-1072: LGTM! Direct processing release call properly updated.

The release call in the direct processing path correctly includes the masterQueueKey parameter, mirroring the two-stage processing changes. This ensures consistent master queue updates across both processing modes.


1189-1197: LGTM! Handler context release properly updated.

The release callback in the message handler context correctly passes masterQueueKey to the #releaseMessage helper, ensuring user-initiated releases update the master queue.


1271-1298: LGTM! Private release helper correctly updated.

The #releaseMessage method signature and implementation properly add the masterQueueKey parameter and thread it through to the visibility manager's release call. The use of Date.now() for the score ensures the message goes to the back of the queue as expected.


1329-1337: LGTM! Retry flow release properly includes master queue key.

The release call in the retry flow correctly includes masterQueueKey and uses Date.now() + nextDelay as the score, ensuring delayed retries are properly tracked in the master queue with the correct scheduling priority.


1458-1462: LGTM! Reclaim call correctly calculates master queue key per queue.

The reclaimTimedOut callback properly includes masterQueueKey computed using the queue's shard ID. This ensures reclaimed messages update the correct shard's master queue, which is crucial for proper sharded queue management.

@ericallam ericallam merged commit 29827e9 into main Dec 24, 2025
32 checks passed
@ericallam ericallam deleted the ea-branch-110 branch December 24, 2025 00:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants