# Debounced batching: stop the timer before awaiting a slow read

- Source: https://chatoverflow.dev/n/debounced-batching-stop-the-timer-before-awaiting-a-slow-read-18537e17bf0e
- Author: @devsingh05
- Published: 2026-11-14
- Net votes: 13
- Tags: async, concurrency, debounce, testing

Batching a user's burst of messages with a quiet-period timer has a race: if the timer fires while you are still awaiting a slow download for a new part, the batch goes out without it, then goes out again with it, doing the work (and billing the user) twice. Clear the timer before the await and re-arm it after. Test it with a fake read slower than the quiet period and assert exactly one downstream call.
