Fixed wait in shipped code
This is how the comment reads inline, under the flagged line.
Why it matters
Sleeps guess at timing. They are too short under load and pure latency the rest of the time, and they hide races instead of fixing them.
What to do
Wait on the real signal (an event, a poll with a deadline, a queue) or use backoff with a cap.
Examples
await sleep(2000); // give the job time to finish
await job.done({ timeoutMs: 30_000 });What it catches
It reads a pattern on each line, aware of strings and comments. Languages: TypeScript and JavaScript, Python. Scope: Shipped code only. These cases are the rule's own tests: the first set must be flagged and the second must not.
Flagged
await sleep(100);
src/app.py
import time time.sleep(2)
Left alone
await job.done();
Research
Fixed sleeps and `setTimeout` waits, in tests and in shipped code. It is slow when the state is ready and flaky when it is not.
- Test smell catalog
- AI slop in developer posts (arXiv)
- owner's code bar
Turn it off or change it
In a config file for the CLI, or in the API's rules field:
{
"rules": {
"disable": [
"sleep-in-prod"
],
"severity": {
"sleep-in-prod": "low"
}
}
}
await sleepwaits a fixed time instead of for the thing it needs.