---
title: "timer-reset-drain-race"
description: "Detect attempts to drain a timer based on Reset's result."
image: "https://strider.gempir.com/og.png"
---

> Documentation Index
> Fetch the complete documentation index at: https://strider.gempir.com/llms.txt
> Use this file to discover all available pages before exploring further.

# timer-reset-drain-race

**Default severity:** `error`

Using `time.Timer.Reset`'s boolean result to decide whether to receive from the
timer channel is racy on older timer implementations and can block with
current synchronous timer channels. Stop and drain before resetting when
compatibility requires it, or reset without conditionally draining afterward.

## Bad

```go
if !timer.Reset(delay) { <-timer.C }
```

## Good

```go
if !timer.Stop() { select { case <-timer.C: default: } }
timer.Reset(delay)
```

Source: https://strider.gempir.com/analyzers/timer-reset-drain-race/index.mdx
