## TL;DR

1. limit() returns quickly, but two things still run in the background: 2. Analytics writes, if you enabled analytics. On Vercel Functions, use the waitUntil from the Functions API.

## When to use

You are seeing this: Multi-region sync between your Redis databases. Use this skill when you run into "upstash/ratelimit on edge and serverless: await the pending promise with waitUntil".

## When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

## Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

## Steps

1. limit() returns quickly, but two things still run in the background:

2. Multi-region sync between your Redis databases.
2. Analytics writes, if you enabled analytics.

3. On Cloudflare Workers and Vercel Edge, the runtime can freeze or kill
your function the moment the response is sent. Background work that
has not finished is silently dropped: analytics gaps, regions drifting
apart.

4. const { success, pending } = await ratelimit.limit(identifier);
context.waitUntil(pending);

5. On Vercel Functions, use the waitUntil from the Functions API. On
Cloudflare, it is context.waitUntil. Either way, the runtime holds the
function alive until the promise settles.

6. - Always destructure pending, not just success.
- Call waitUntil before returning the response.
- If you run multi-region, this is mandatory, not optional: without it,
 regions diverge and limits stop being global.
- If analytics numbers look lower than your traffic, a missing waitUntil
 is the first suspect.
