UND_ERR_HEADERS_TIMEOUT
when changing system time during fetch
#3493
Labels
bug
Something isn't working
UND_ERR_HEADERS_TIMEOUT
when changing system time during fetch
#3493
Bug Description
When the system time is changed forward by more than 5 minutes during a
fetch()
call, the operation terminates withUND_ERR_HEADERS_TIMEOUT
.As far as I can tell, this is due to how the timeout mechanism is implemented in
lib/util/timers.js
.Timers above 1000 ms are realized with a custom, low resolution timer implementation, which relies on
Date.now()
. Therefore the timers are influenced by the system time. (I guess this would also mean the timeout would fire late/never when time is set back during an activefetch()
operation too.)In my testing, JS inbuilt
setTimeout()
is not impacted by system time changes.Is this expected behavior?
Are there valid reasons why the timeout should be relative to the wall clock?
If this is a bug, could monotonic time functions like
performance.now()
orprocess.hrtime
be used here instead?Reproducible By
headersTimeout
Here is an unit test that verifies the early timeout for
test/util.js
:Expected Behavior
A
fetch()
calls timeout should not be influenced by system time.Environment
Observed in Node v18.14.2, unit test written for undici on current main (69cfd97).
The text was updated successfully, but these errors were encountered: