-
Notifications
You must be signed in to change notification settings - Fork 4
add rate limit handling to trigger and action execution #41
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds configurable rate limit delays to trigger and action executions by reading rateLimit from cfg.nodeSettings and awaiting before proceeding.
- Introduces a wait after each API call in
trigger.jsandaction.js - Defaults the delay to 1700 ms if no valid
rateLimitis provided
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| templates/lib/triggers/trigger.js | Added a delay block after executeCall using rateLimit |
| templates/lib/actions/action.js | Added a delay block after executeCall using rateLimit |
| const { body, headers } = await executeCall.call(this, callParams); | ||
|
|
||
| // Wait for rate limit if specified | ||
| const rateLimit = cfg.nodeSettings && cfg.nodeSettings.rateLimit ? parseInt(cfg.nodeSettings.rateLimit) : 1700; |
Copilot
AI
Jul 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specify the radix when using parseInt (e.g., parseInt(cfg.nodeSettings.rateLimit, 10)) to avoid unexpected behavior with leading zeros.
| const rateLimit = cfg.nodeSettings && cfg.nodeSettings.rateLimit ? parseInt(cfg.nodeSettings.rateLimit) : 1700; | |
| const rateLimit = cfg.nodeSettings && cfg.nodeSettings.rateLimit ? parseInt(cfg.nodeSettings.rateLimit, 10) : 1700; |
| const resp = await executeCall.call(this, callParams); | ||
|
|
||
| // Wait for rate limit if specified | ||
| const rateLimit = cfg.nodeSettings && cfg.nodeSettings.rateLimit ? parseInt(cfg.nodeSettings.rateLimit) : 1700; |
Copilot
AI
Jul 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a radix parameter to parseInt (e.g., parseInt(cfg.nodeSettings.rateLimit, 10)) for consistent parsing across environments.
| const rateLimit = cfg.nodeSettings && cfg.nodeSettings.rateLimit ? parseInt(cfg.nodeSettings.rateLimit) : 1700; | |
| const rateLimit = cfg.nodeSettings && cfg.nodeSettings.rateLimit ? parseInt(cfg.nodeSettings.rateLimit, 10) : 1700; |
| do { | ||
| const { body, headers } = await executeCall.call(this, callParams); | ||
|
|
||
| // Wait for rate limit if specified |
Copilot
AI
Jul 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rate-limit logic is duplicated in both trigger and action modules; consider extracting it into a shared helper function to reduce code repetition.
| // Wait for rate limit if specified | ||
| const rateLimit = cfg.nodeSettings && cfg.nodeSettings.rateLimit ? parseInt(cfg.nodeSettings.rateLimit) : 1700; | ||
| if (rateLimit > 0) { | ||
| this.logger.info(`Waiting for rate limit: ${rateLimit} ms`); |
Copilot
AI
Jul 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Rate-limit logs can be verbose at info level; consider using debug or a lower verbosity level to prevent log noise in production.
| this.logger.info(`Waiting for rate limit: ${rateLimit} ms`); | |
| this.logger.debug(`Waiting for rate limit: ${rateLimit} ms`); |
No description provided.