Skip to content

Updated queue/concurrency docs for v4 #2418

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 20, 2025

Conversation

matt-aitken
Copy link
Member

No description provided.

Copy link

changeset-bot bot commented Aug 19, 2025

⚠️ No Changeset found

Latest commit: 51e0425

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

Copy link
Contributor

coderabbitai bot commented Aug 19, 2025

Walkthrough

Documentation for queue/concurrency was rewritten to center on queues rather than per-task concurrency. Default concurrency is now described as bounded by environment limits; “burst limits” terminology is used. The “Setting the concurrency when you trigger a run” section becomes “Setting the queue when you trigger a run,” with examples showing queue overrides (e.g., paid vs free). Per-tenant behavior clarifies that concurrencyKey duplicates a queue per key value. Subtasks are stated not to inherit the parent’s queue. Content about same-queue waits and deadlocks was removed. Behavior for waiting on subtasks in different queues remains, with wording aligned to queue terminology.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch queue-concurrency-docs-improvements

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
docs/queue-concurrency.mdx (2)

74-96: Define the “free-users” queue and normalize comment style

Later examples reference a “free-users” queue with concurrencyLimit: 1, but it isn’t defined. Adding it here prevents confusion. Also normalize comment casing/spacing and TODO.

 ```ts /trigger/override-concurrency.ts
 const paidQueue = queue({
   name: "paid-users",
   concurrencyLimit: 10,
 });
+
+const freeQueue = queue({
+  name: "free-users",
+  concurrencyLimit: 1,
+});
 
 export const generatePullRequest = task({
   id: "generate-pull-request",
   queue: {
-    //normally when triggering this task it will be limited to 1 run at a time
+    // Normally, triggering this task uses its default queue with a concurrency limit of 1
     concurrencyLimit: 1,
   },
   run: async (payload) => {
-    //todo generate a PR using OpenAI
+    // TODO: generate a PR using OpenAI
   },
 });

---

`126-158`: **Clarify concurrencyKey semantics and align examples with defined queues**

Two issues:
- “Creates a copy of the queue” is imprecise; it partitions the queue per key with independent counters.
- Comments claim “free-users” has concurrencyLimit: 1 but the queue wasn’t defined until the earlier fix. Make that explicit in comments to avoid implying implicit defaults.




```diff
-You can do this by using `concurrencyKey`. It creates a copy of the queue for each unique value of the key.
+You can do this by using `concurrencyKey`. It partitions the queue by key so each unique key value gets its own independent concurrency counters.

-    //the "free-users" queue has a concurrency limit of 1
+    // The "free-users" queue (defined above) has a concurrency limit of 1
@@
-      //this creates a free-users queue for each user
+      // This partitions the "free-users" queue per userId (independent concurrency per user)
@@
-    //the "paid-users" queue has a concurrency limit of 10
+    // The "paid-users" queue (defined above) has a concurrency limit of 10
@@
-      //this creates a paid-users queue for each user
+      // This partitions the "paid-users" queue per userId (independent concurrency per user)
🧹 Nitpick comments (5)
docs/queue-concurrency.mdx (5)

6-8: Good intro; minor wording to tighten “limited by” phrasing

The new queue-first framing reads well. Consider a small clarity tweak to avoid the “limited by limit” phrasing and align with later sections.

-By default, each task gets its own queue and the concurrency is only limited by your environment concurrency limit. If you need more control (for example, to limit concurrency or share limits across multiple tasks), you can define a custom queue as described later.
+By default, each task gets its own queue and effective concurrency is bounded by your environment’s concurrency limits. If you need more control (for example, to limit concurrency or share limits across multiple tasks), you can define a custom queue as described later.

16-16: Avoid tautology in “unbounded … limited only by …”

Reads as contradictory. Suggest simplifying to match the queue-first model and the “bounded by environment” wording.

-By default, all tasks have an unbounded concurrency limit, limited only by the overall concurrency limits of your environment.
+By default, tasks do not set an explicit concurrencyLimit; effective concurrency is bounded by your environment’s limits.

19-24: Minor copyedit: punctuation and consistency around “burst/burstable”

Optional polish: add a comma after “customer” and keep “burst” terminology consistent.

-  but any single queue can have at most 10 concurrent runs. If you're a paying customer you can
-  request higher burst limits by [contacting us](https://www.trigger.dev/contact).
+  but any single queue can have at most 10 concurrent runs. If you're a paying customer, you can
+  request higher burst limits by [contacting us](https://www.trigger.dev/contact).

162-162: Punctuation and explicitness about overrides

Add a period and make it explicit that subtasks can set their own queue.

-When you trigger a task that has subtasks, the subtasks will not inherit the queue from the parent task. Unless otherwise specified, subtasks will run on their own queue
+When you trigger a task that has subtasks, the subtasks will not inherit the queue from the parent task. Unless otherwise specified, subtasks will run on their own queue.

213-217: Move/adjust checkpoint comment to the await location

The checkpoint occurs at the await. Place the comment at that line for accuracy.

-    //trigger a subtask and wait for it to complete
-    await subtask.triggerAndWait(payload);
-    // The parent task checkpoints here and releases its concurrency slot
-    // allowing other tasks to execute while waiting
+    // Trigger a subtask and wait for it to complete.
+    // The parent task checkpoints at this await and releases its concurrency slot,
+    // allowing other tasks to execute while waiting.
+    await subtask.triggerAndWait(payload);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 32e3fab and 51e0425.

📒 Files selected for processing (1)
  • docs/queue-concurrency.mdx (7 hunks)
🧰 Additional context used
🧠 Learnings (5)
📚 Learning: 2025-08-18T10:07:17.345Z
Learnt from: CR
PR: triggerdotdev/trigger.dev#0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-08-18T10:07:17.345Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Define tasks using task({ id, run, ... }) with a unique id per project

Applied to files:

  • docs/queue-concurrency.mdx
📚 Learning: 2025-08-18T10:07:17.345Z
Learnt from: CR
PR: triggerdotdev/trigger.dev#0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-08-18T10:07:17.345Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : For idempotent child-task invocations, create and pass idempotencyKey (and optional TTL) when calling trigger()/batchTrigger() from tasks

Applied to files:

  • docs/queue-concurrency.mdx
📚 Learning: 2025-08-18T10:07:17.345Z
Learnt from: CR
PR: triggerdotdev/trigger.dev#0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-08-18T10:07:17.345Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Export every task (including subtasks) defined with task(), schedules.task(), or schemaTask()

Applied to files:

  • docs/queue-concurrency.mdx
📚 Learning: 2025-08-18T10:07:17.345Z
Learnt from: CR
PR: triggerdotdev/trigger.dev#0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-08-18T10:07:17.345Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : When triggering a task multiple times in a loop from inside another task, use batchTrigger()/batchTriggerAndWait() instead of per-item trigger() calls

Applied to files:

  • docs/queue-concurrency.mdx
📚 Learning: 2025-08-18T10:07:17.345Z
Learnt from: CR
PR: triggerdotdev/trigger.dev#0
File: .cursor/rules/writing-tasks.mdc:0-0
Timestamp: 2025-08-18T10:07:17.345Z
Learning: Applies to **/trigger/**/*.{ts,tsx,js,jsx} : Use schedules.task(...) for scheduled (cron) tasks; do not implement schedules as plain task() with external cron logic

Applied to files:

  • docs/queue-concurrency.mdx
⏰ 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). (1)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
docs/queue-concurrency.mdx (1)

98-121: Queue override example: apply style nits and confirm trigger options API

  • In docs/queue-concurrency.mdx (around lines 98–121), update the inline comments for consistency and clarity:
   if (data.branch === "main") {
-    //trigger the task, with the paid users queue
+    // Trigger the task using the paid-users queue
     const handle = await generatePullRequest.trigger(data, {
       queue: "paid-users",
     });
 
     return Response.json(handle);
   } else {
-    //triggered with the default queue (concurrency of 1)
+    // Triggered with the task’s default queue (concurrencyLimit: 1)
     const handle = await generatePullRequest.trigger(data);
     return Response.json(handle);
   }
  • Confirmed that the trigger method accepts an options object of shape { queue: string; concurrencyKey?: string }.

@D-K-P D-K-P merged commit 8483900 into main Aug 20, 2025
7 checks passed
@D-K-P D-K-P deleted the queue-concurrency-docs-improvements branch August 20, 2025 10:47
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