Skip to content

Conversation

@arcoraven
Copy link
Contributor

@arcoraven arcoraven commented Jul 3, 2025

Changes

  • Added a new environment variable SEND_WEBHOOK_QUEUE_CONCURRENCY to control the concurrency of the webhook sending queue
  • Updated the webhook worker to use this configurable concurrency value instead of the hardcoded value of 10
  • Set a default value of 10 to maintain backward compatibility

How this PR will be tested

  • Set SEND_WEBHOOK_QUEUE_CONCURRENCY=20 in the environment and verify that the webhook worker uses this value
  • Leave the environment variable unset and verify that the default value of 10 is used
  • Monitor webhook processing performance with different concurrency values

Output

# Example environment configuration
SEND_WEBHOOK_QUEUE_CONCURRENCY=20

Summary by CodeRabbit

  • New Features
    • Added support for configuring webhook queue concurrency through an environment variable, allowing dynamic adjustment without code changes.

@coderabbitai
Copy link

coderabbitai bot commented Jul 3, 2025

Walkthrough

A new environment variable, SEND_WEBHOOK_QUEUE_CONCURRENCY, was introduced with a default value of 10. The worker responsible for sending webhooks now uses this environment variable to determine its concurrency level instead of a hardcoded value.

Changes

File(s) Change Summary
src/shared/utils/env.ts Added SEND_WEBHOOK_QUEUE_CONCURRENCY to environment schema and runtime mapping with default.
src/worker/tasks/send-webhook-worker.ts Updated worker to use env.SEND_WEBHOOK_QUEUE_CONCURRENCY for concurrency configuration.

Sequence Diagram(s)

sequenceDiagram
    participant Env as Environment
    participant Worker as SendWebhookWorker

    Env->>Worker: Provide SEND_WEBHOOK_QUEUE_CONCURRENCY value (default 10)
    Worker->>Worker: Initialize with concurrency from env
    Worker->>WebhookQueue: Process webhooks with configured concurrency
Loading

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • INF-171: Entity not found: Issue - Could not find referenced Issue.
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • Explain this complex logic.
    • 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. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

  • 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.

@arcoraven arcoraven marked this pull request as ready for review July 3, 2025 18:08
Copy link
Contributor Author

arcoraven commented Jul 3, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link

@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)
src/shared/utils/env.ts (1)

97-97: Consider adding validation bounds for concurrency value.

The implementation looks good and follows the established pattern. However, consider adding validation to ensure the concurrency value is a positive integer, as negative or zero values could cause issues with the BullMQ worker.

-    SEND_WEBHOOK_QUEUE_CONCURRENCY: z.coerce.number().default(10),
+    SEND_WEBHOOK_QUEUE_CONCURRENCY: z.coerce.number().min(1).default(10),
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3baf200 and eb96c44.

📒 Files selected for processing (2)
  • src/shared/utils/env.ts (2 hunks)
  • src/worker/tasks/send-webhook-worker.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
src/shared/utils/env.ts (1)
Learnt from: d4mr
PR: thirdweb-dev/engine#897
File: src/shared/utils/env.ts:106-115
Timestamp: 2025-06-09T23:36:29.144Z
Learning: In the mine worker polling configuration, EXPERIMENTAL__MINE_WORKER_BASE_POLL_INTERVAL_SECONDS can intentionally be set higher than EXPERIMENTAL__MINE_WORKER_MAX_POLL_INTERVAL_SECONDS when combined with a low EXPERIMENTAL__MINE_WORKER_POLL_INTERVAL_SCALING_FACTOR. This creates a gradual backoff curve where the actual interval starts low (base * attempts * scaling_factor) and ramps up until capped by the max value, allowing for fine-grained control over polling behavior.
🧬 Code Graph Analysis (1)
src/worker/tasks/send-webhook-worker.ts (1)
src/shared/utils/env.ts (1)
  • env (23-181)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: build
  • GitHub Check: lint
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (3)
src/shared/utils/env.ts (1)

172-172: Environment variable mapping is correctly implemented.

The runtime environment mapping follows the established pattern and correctly maps the environment variable to the schema definition.

src/worker/tasks/send-webhook-worker.ts (2)

26-26: Clean import of the environment configuration.

The import statement is correctly added and follows the established import pattern in the codebase.


106-106: Successfully replaces hardcoded concurrency with configurable value.

The change correctly replaces the hardcoded value with the environment variable, maintaining the same default behavior (10) while enabling runtime configuration. This achieves the PR objective of making webhook queue concurrency configurable.

@arcoraven arcoraven merged commit 9a8a054 into main Jul 3, 2025
9 checks passed
@arcoraven arcoraven deleted the ph/07-04-chore_expose_webhook_concurrency_in_env_var branch July 3, 2025 18:12
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.

2 participants