ofetch icon indicating copy to clipboard operation
ofetch copied to clipboard

FETCH_KEEP_ALIVE not respected when using native fetch

Open antoinerey opened this issue 1 year ago • 0 comments

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.

CleanShot 2023-11-23 at 17 11 55@2x

Logs

No response

antoinerey avatar Nov 23 '23 16:11 antoinerey