Handling Rate Limits in Custom Declarative Nodes

Question

Dear n8n-Team,

while building custom nodes I am currently thinking about how to properly handle rate-limiting inside the custom node (especially with pagination handling). Is there a recommended way on how to implement this on a node-basis?

Ideally the users of my node would not have to build something a la Handling API rate limits | n8n Docs, but the node “just” takes longer (or users could provide a timout as the parameter).

Research Results

While digging through existing nodes I’ve stumbled upon the following section of the Google Calendar node:


if (error.httpCode === '403' || error.httpCode === '429') {
	const delay = 1000 * Math.pow(2, retryCount);

	console.log(`Rate limit hit. Retrying in {delay}ms... (Attempt {retryCount + 1})`); // !sic: community.n8n.io crashes with a Cloudflare Error if using Template Literals inside a Markdown Code Block

	await sleep(delay);
	return await requestWithRetries(node, requestFn, retryCount + 1, maxRetries, itemIndex);
}

which is close to what I want to achieve, but I don’t see an easy way on using this piece of code as an interceptor for the operation of a declarative node.

tldr;

Using the declarative approach for custom nodes, is there a way to add rate limit handling/http interception capabilities?

Thanks a lot in advance!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.