A 2-second polling loop fired roughly 1,800 fetch requests an hour just to catch one status change.
An AbortController-guarded fetch with a 30-second timeout cut that to under 10 requests an hour.
The new approach still caught a stalled job within 30 seconds, the same ceiling the polling loop had.
Polling still wins only when the client can't hold a connection open, which ruled it out for my own case.
I had a background job checker in one of my tools pinging an endpoint every two seconds to see if a video export had finished. It worked, but it was doing roughly 1,800 requests an hour to answer one question that only changed state once. Swapping the loop for a single fetch wrapped in an AbortController timeout dropped that to single digits an hour without losing the speed the UI needed.
What the polling loop was actually costing
The setInterval version was simple to write, which is exactly why I'd never looked hard at it. Every two seconds: fetch the job status, check a field, clear the interval if it's done. Simple to read, cheap to write, and I'd shipped three other tools the same way before I ever timed it.
The cost wasn't CPU. A fetch every two seconds barely registers on a desktop.
It was everything downstream of the fetch: a server hit that has to touch a database or a job queue, a response that has to serialize even when nothing changed, and on a phone, a radio wake-up every two seconds even if the screen is off. I watched this in Chrome's network panel for a five-minute export and counted 150 identical requests, 149 of which returned the exact same "still running" payload.
One good answer, buried in 149 copies of "not yet."
That's the part that's easy to miss when you're building alone. Nobody reviews your polling interval in a pull request. You pick two seconds because one second feels too chatty and five feels too slow, ship it, and move on. The bill shows up later as server load or, on the error log I read every morning before anything else, as a spike of 429s from a job endpoint that was never meant to take that kind of traffic.
The fix isn't to poll less often. A slower poll just trades responsiveness for a load you're still paying, at a worse user experience. The fix is to stop asking a question you can answer with one well-timed request instead of forty badly-timed ones.
I didn't believe the 1,800 number until I counted it myself, twice, on two different days.
How the AbortController version actually works
The replacement is one fetch call with a timeout attached through AbortController, not a chain of them. You create a controller, pass its signal to fetch, and start a timer that calls controller.abort() if nothing comes back in time:
async function checkJobOnce(jobId, timeoutMs = 30000) { const controller = new AbortController(); const timer = setTimeout(() => controller.abort(), timeoutMs); try { const res = await fetch(`/jobs/${jobId}`, { signal: controller.signal }); return await res.json(); } finally { clearTimeout(timer); } } That alone doesn't replace polling, it just gives you a fetch that won't hang forever. The actual swap is on the server: instead of answering "still running" immediately, the endpoint holds the request open and only responds when the job finishes or the timeout is close.
The client still calls this in a loop, but the loop only re-fires when a request ends, either with an answer or with the abort. A 30-second ceiling that used to cost 15 round trips now costs one, or at most two if the job runs long.
That's the whole trick. Hold the question open instead of asking it again.
I'd built something close to this before without naming it: the same pattern of "wait, then give up" is underneath the retry delay I replaced with exponential backoff and jitter. A timeout you control on your own terms beats a fixed interval you picked by feel, in both directions. I'd just never connected the two until I wrote this one down.
What I measured switching from one to the other
I ran both versions against the same export job, one that reliably takes between 12 and 40 seconds depending on file size, twenty times each, logging every request to a plain text file so I could count them by hand afterward instead of trusting a dashboard.
The polling version averaged 14 requests per job at a 2-second interval, all but one of them returning "still running." Total time to detect completion was within 2 seconds of the actual finish, which makes sense since that's the floor the interval sets. Nothing surprising there, it's exactly what you'd expect from the math.
The abort version made one request per job in 17 of the 20 runs, since most jobs finished inside the 30-second window the server held the connection open for. The other 3 runs needed a second request because the job ran past 30 seconds. Detection time matched the polling version almost exactly, usually within a second, because the server pushes the answer the moment the job finishes instead of waiting for the next poll tick.
No real speed cost. That part held up better than I expected going in.
Request count dropped from roughly 14 per job to roughly 1.15. Scaled to an hour of a user leaving a tab open and re-running exports, that's the 1,800-to-under-10 gap in the TLDR. Server load for that one endpoint fell enough that it stopped showing up in my own slow-query list at all, which is a strange thing to feel good about, but I did.
The one thing that got slightly worse: a dropped connection. A flaky mobile network kills a 30-second held-open request more often than it kills a 2-second one, because there's more time for something to go wrong mid-request. I had to add a plain retry around the abort version to match the resilience the dumb polling loop had by accident, since a short request that fails just tries again two seconds later anyway, no extra code required.
That retry took four lines. It felt like cheating how little it cost to close the gap.
Where polling still wins, and what I'd use instead
I wouldn't tell anyone to rip out every polling loop they own. Polling still wins when the client genuinely can't hold a connection open: serverless functions with a hard execution limit, a server behind a load balancer that kills idle connections at 60 seconds, or a backend you don't control and can't change to support long-polling in the first place. That last one is the real reason I didn't ship this everywhere. One of my tools talks to a third-party API that returns instantly no matter what, so there's nothing to hold open and no reason to build the abort version at all.
No server change possible, no abort trick. The loop stays.
For my own backend, where I control both sides, this was close to a pure win. The number that convinced me wasn't the request count, it was watching the network panel go quiet. A tool that pings its own server 1,800 times an hour to ask the same question looks fine in isolation and terrible the moment you have five tabs open, or a handful of users doing the same thing at once.
I'd also add a word of caution here, since it's easy to over-apply this once it works once: don't hold a connection open past your own infrastructure's timeout just to chase a cleaner number. I tried 60 seconds first and a reverse proxy in front of the API killed it at 30 anyway, silently, which cost me an afternoon of confused debugging before I found the actual limit in the proxy's own config.
If I were doing this today and didn't control the server, I'd reach for a shorter interval with exponential backoff instead, starting at 2 seconds and doubling up to a 15-second ceiling. It's not as clean as the held-open request, but it cuts the same waste without needing a server change, and it's the same backoff idea I'd already tested for retries.
Same idea, cheaper to ship, slightly worse numbers.
Either way, the fix is the same: stop asking on a fixed clock and start asking only when the answer might actually be different.
Bottom Line
A polling loop is the easiest thing to write and the easiest thing to forget about once it's running. Mine sat in production for months firing 1,800 near-identical requests an hour before I ever opened the network panel on it. The AbortController version isn't more clever code, it's roughly the same line count, but it asks a question once and waits for a real answer instead of asking the same question forty times until one of the answers changes.
It's a small enough change that I almost didn't write it up. Then I looked at the request count and changed my mind.
If you own both sides of the connection, swap the interval for a held-open request with an abort timeout and measure your own request count before and after, on a real job, not a synthetic one that always finishes in two seconds. If you don't own the server, exponential backoff gets you most of the same saving without touching anything you can't change, and it costs you an afternoon at most to retrofit onto an existing loop.
Either way, check the number before you decide it's not worth fixing. Mine looked harmless until I counted it, and the count is the only part of this that actually convinced me.

