I'm trying to find a solution for the TEN_SECONDLY_ROLLING error with one of our workflows. It was suggested to me to create a function that processes our calls in smaller batches with a delay of 10 or more seconds. I've written a code that doesn't seem to run into any errors, but also doesn't give the delay I'd expect. I'm still seeing 200+ calls in a 10 second window.
What would be a better solution for this issue than the code below?
static async sleep(milliseconds) {
const date = Date.now();
let currentDate = null;
do {
currentDate = Date.now();
} while (currentDate - date < milliseconds);
}
Scott Marion Senior Developer @ Thread Connected Marketing
A classic case for me is a workflow (that includes API calls in custom code workflow steps) triggered by an import lets say. If the import contains many records, I try and spread the delay of the workflow trigger for groups of contacts based on a "random" number for each contact.
In fact I often use the HubSpot record ID as a randomizer - the last digit for example can help set up 10 options of programmable delay, which is often enough to avoid the API rate crunch.
Just bear in mind that custom code workflow steps can only last a max of 20 wallclock seconds - including sleep time. So I have found that a delay function has to be teased apart from the actual API call functions to portion out your API call resources into usuable chuncks.
Hi SteveHTM, thank you for your reply. I'm a little new to working with API, could you explain what the difference is in seperating the delay from the other call functions?
A classic case for me is a workflow (that includes API calls in custom code workflow steps) triggered by an import lets say. If the import contains many records, I try and spread the delay of the workflow trigger for groups of contacts based on a "random" number for each contact.
In fact I often use the HubSpot record ID as a randomizer - the last digit for example can help set up 10 options of programmable delay, which is often enough to avoid the API rate crunch.
static async sleep(milliseconds) {
const date = Date.now();
let currentDate = null;
do {
currentDate = Date.now();
} while (currentDate - date < milliseconds);
}
Scott Marion Senior Developer @ Thread Connected Marketing