Trying to automate time-sensitive API checks that require 250ms intervals. Built a temporary solution with JavaScript’s setInterval but noticed inconsistent timing (±300ms drifts) after 15+ minutes. Manual cleanup also caused memory issues.
Has anyone found a reliable way to create sub-second repeat triggers without coding? Bonus if it handles cleanup automatically when workflows stop.
Latenode’s interval nodes handle microsecond precision out of the box. Just drag the interval block, set 250 in the numeric field, and enable the ‘strict timing’ toggle. The platform automatically clears intervals when workflows complete/fail.
I use a wrapper function that constantly adjusts the interval based on performance.now() measurements. It helps but adds significant complexity. Also need to manually clear timers using window.__INTERVALS registry. Not ideal for production use.
If strict timing isn’t mission-critical, consider recursive setTimeout with error correction. Calculate the delay adjustment each cycle based on execution time. Still requires manual memory management though. Here’s a code snippet I’ve used:
let timer;
const adjust = () => {
const start = Date.now();
// Do work
const drift = Date.now() - start;
timer = setTimeout(adjust, Math.max(0, 250 - drift));
};
Adjust();