nodejs / nodejs/undici

tcp connections taking too long to close

Open
#1,135 14 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
7.7k
Forks
880
Avg merge
2d 16h
Merged PRs (30d)
68

Description

Bug Description

We recently migrated our http client from request-promise-native to undici on our GraphQL server. We have observed significant performance gains 🎉.

  • Our GraphQL server connects through upstream micro-services through HTTP connection.
  • After this migration we observed that connections between GraphQL and upstream services are not draining on regular interval.
  • Upstream services are deployed using blue green deployments.
  • Even after we deploy new stack of upstream service, there are connection open on older stack for more than 1.5 hrs.

Is there a config to specify to drain the TCP connections on certain intervals

Additional context

Sample Code-

import {IncomingHttpHeaders} from 'http'
import {request} from 'undici'

export const nativePostRequest = async (
  url: string,
  headers: IncomingHttpHeaders,
  body: any,
  extra: string
) => {
  const bodyString = JSON.stringify(body)
  return await request(url, {
    method: 'POST',
    headers: headers,
    body: bodyString,
    bodyTimeout: config.httpTimeout
  })
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the sample request(url, ...) entry point and investigate how Undici manages HTTP/TCP connection lifetimes after requests complete. Check whether the client exposes a documented drain or interval setting, and verify any finding against the blue-green deployment scenario described. Done means identifying a supported configuration or clearly documenting the limitation and expected connection behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.