Member Junction
    Preparing search index...
    • Discards a fetch Response body so its underlying connection can return to the keep-alive pool instead of being held open until GC finalizes an unconsumed stream. Node's fetch (undici) pins the connection to any Response whose body was never read or cancelled.

      Call this on a Response you're about to throw away without reading — most commonly an error-status branch that returns/throws before calling .json()/.text()/etc. HttpRequest and HttpClient already do this for you; reach for it directly only when a call site uses raw fetch() or SafeFetch instead of going through them.

      Parameters

      • response: Response

      Returns Promise<void>

      const response = await fetch(url);
      if (!response.ok) {
      await DrainResponseBody(response);
      throw new Error(`request failed: ${response.status}`);
      }