This is a race condition. Consider a spurious wakeup one nanosecond before timeout and a context switch such that `uv_hrtime() - hrtime > ms`.
```c
static void delay(uint64_t ms) {
  int64_t ns;
  uint64_t hrtime;

  assert(ms < INT64_MAX/1000000);
  ns = ms * 1000000;
  while (ns > 0) {
    hrtime = uv_hrtime();
    if (uv_cond_timedwait(&delay_cond, &delay_mutex, ns) == UV_ETIMEDOUT)
      break;
    ns -= uv_hrtime() - hrtime;
  }
}
```
Same thing above.