Skip to content

Conversation

@shulkaolka
Copy link
Contributor

No description provided.

@shulkaolka shulkaolka requested a review from Copilot July 2, 2025 12:34
Copy link

Copilot AI left a 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.js and action.js
  • Defaults the delay to 1700 ms if no valid rateLimit is 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;
Copy link

Copilot AI Jul 2, 2025

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.

Suggested change
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;

Copilot uses AI. Check for mistakes.
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;
Copy link

Copilot AI Jul 2, 2025

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.

Suggested change
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;

Copilot uses AI. Check for mistakes.
do {
const { body, headers } = await executeCall.call(this, callParams);

// Wait for rate limit if specified
Copy link

Copilot AI Jul 2, 2025

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.

Copilot uses AI. Check for mistakes.
// 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`);
Copy link

Copilot AI Jul 2, 2025

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.

Suggested change
this.logger.info(`Waiting for rate limit: ${rateLimit} ms`);
this.logger.debug(`Waiting for rate limit: ${rateLimit} ms`);

Copilot uses AI. Check for mistakes.
@shulkaolka shulkaolka merged commit 34e62ef into main Jul 2, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants