‹ BackHN Continuity

Thread

Small programming tricks

681 points · 294 comments · signa11

  1. forty · · focus · HN ↗
    > In NodeJS, you can keep a connection open to an external resource by creating an https.Agent and then providing it to your http requests: fetch(url, {method, agent}). This can have a dramatic impact on latency.

    Is it true that you can pass a nodejs agent to fetch ? I don't think so

    1. nulltrace · · focus · HN ↗
      No. Node's built-in fetch uses Undici. The custom hook is dispatcher, with an Undici-compatible dispatcher: fetch(url, { dispatcher })
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.