Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions templates/lib/actions/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ async function processAction(msg, cfg, snapshot, incomingMessageHeaders, tokenDa

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.
if (rateLimit > 0) {
this.logger.info(`Waiting for rate limit: ${rateLimit} ms`);
await new Promise(resolve => setTimeout(resolve, rateLimit));
}

const newElement = {};
newElement.metadata = getMetadata(msg.metadata);
newElement.data = resp.body;
Expand Down
7 changes: 7 additions & 0 deletions templates/lib/triggers/trigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ async function processTrigger(msg, cfg, snapshot, incomingMessageHeaders, tokenD
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.
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.
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.
await new Promise(resolve => setTimeout(resolve, rateLimit));
}

const newElement = {};
newElement.metadata = getMetadata(msg.metadata);
newElement.data = getElementDataFromResponse.call(this, arraySplittingKey, body);
Expand Down