Skip to content

VBC-008: sleep-race-condition

warning

Category: clean-code
Analysis: Regex (line by line)
File types: .js, .ts, .tsx, .astro
Scope: source code only, ignoring anything inside strings and comments
Tags: clean-code robustness

What it reports

Using setTimeout as a sleep to paper over a race condition at line {line}. This is a flaky band-aid that slows the app down. Fix the underlying async coordination with proper event handling or promises instead.

Flagged

js
await new Promise(resolve => setTimeout(resolve, 500));

Not flagged

js
await waitForReady();

Pattern

regex
await\s+new\s+Promise\s*\([^)]*setTimeout

Released under the MIT License.