Repository navigation
Update disabling-http-keep-alive.md for server-side only - #43374
Conversation
Fixes vercel#43354 It is not possible to specify an `agent` on a single `fetch()` call since the types for `fetch` come from TypeScript where `agent` is not supported as an option.
e078ebe to
6b863fe
Compare
|
You said it’s not possible with TS types but what about with JS? Are the types wrong? I also think the behavior is different for Node.js 16 vs 18 because it’s no longer poly filled on 18, it’s native. |
The TypeScript However because Next.js supports also using With Next.js 13 running on Node 18, you're right However running on Node <18 Next.js polyfills So I guess this is a super complex scenario where the type is not sophisticated enough to know if you're running I think the TypeScript type definition of |
| To disable HTTP Keep-Alive for all `fetch()` calls on the server-side, open `next.config.js` and add the `httpAgentOptions` config: | ||
|
|
||
| ```js | ||
| module.exports = { |
There was a problem hiding this comment.
I believe this uses the same Agent behavior so it probably wont work either on Node.js 18
cc @Ethan-Arrowood who implemented undici and might know more
There was a problem hiding this comment.
Based on our testing, unfortunately these agent options aren't compatible with undici and there's no equivalent alternative.
We had to intentionally disable Node 18's undici with --no-experimental-fetch
There was a problem hiding this comment.
undici's fetch accepts dispatcher which fulfills a similar role as agent though it requires undici specific Pool/Agent/etc instead of node's http agent.
Co-authored-by: Steven <[email protected]>
For anyone else that encounters this -- I mistook this as suggesting new behavior in Next 13, when I believe actually any previous version of Next running on Node18 will use undici and not the fetch polyfill: |
fixes #43354
It is not possible to specify an
agenton a singlefetch()call since the types forfetchcome from TypeScript whereagentis not supported as an option.