ofetch
ofetch copied to clipboard
FETCH_KEEP_ALIVE not respected when using native fetch
Environment
- Node.js v18.18.2
- ofetch v1.3.3
Reproduction
Run the following with FETCH_KEEP_ALIVE=true set.
import { fetch } from 'ofetch'
fetch('/wherever')
Describe the bug
Following the documentation on keepalive, it seems that FETCH_KEEP_ALIVE should be able to keep connection open on Node.js. However, it does not seem to work on my side, using Node.js v18.18.2.
We're using native fetch as it's available, and thus I suspect that FETCH_KEEP_ALIVE is not respected in such cases.
Additional context
According to what I understood when reading the code, it seems to confirm my theory. The FETCH_KEEP_ALIVE env variable is not used if globalThis.fetch
is defined, and thus never applies to Node.js version where native fetch is available.
Logs
No response