Capítulo 218 de 456

httpAgentOptions

Core Idea

Controls HTTP Keep-Alive for server-side fetch() calls on Node.js versions prior to 18, where Next.js polyfills fetch() with undici and enables Keep-Alive by default.

Key Concepts

  • httpAgentOptions.keepAlive: boolean; set false to disable Keep-Alive for all server-side fetch() calls.

Code Examples

module.exports = {
  httpAgentOptions: {
    keepAlive: false,
  },
}
  • O que demonstra: desabilitar HTTP Keep-Alive globalmente no servidor.

Key Takeaways

  1. Relevante só em Node.js < 18 (onde Next.js faz polyfill de fetch com undici e ativa Keep-Alive por padrão).
  2. Afeta apenas chamadas fetch() do lado servidor.

Connects To

  • fetch data fetching: comportamento de rede afetado por esta config em runtimes Node antigos.