nodejs / nodejs/node

Process does not exit after https request with keepAlive enabled (now default in Node 19)

Open
#47,228 18 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

confirmed-bug http https
Dominant language
JavaScript
Stars
122k
Forks
37.3k
Avg merge
4d 2h
Merged PRs (30d)
283

Description

Version

v19.8.1

Platform

Linux Jake-Framework 6.2.7-arch1-1 #1 SMP PREEMPT_DYNAMIC Sat, 18 Mar 2023 01:06:36 +0000 x86_64 GNU/Linux

Subsystem

https

What steps will reproduce the bug?

Run a script containing:

const https = require("https");
const url = "https://github.com/dprint/dprint/releases/download/0.35.3/dprint-x86_64-unknown-linux-gnu.zip";
https.get(url, { method: "HEAD" }, console.log);

This will hang.

How often does it reproduce? Is there a required condition?

100% of the time; downgrade to Node 18 and it no longer hangs.

What is the expected behavior? Why is that the expected behavior?

No hang. Run this:

const https = require("https");
const url = "https://github.com/dprint/dprint/releases/download/0.35.3/dprint-x86_64-unknown-linux-gnu.zip";
https.get(url, { method: "HEAD", agent: new https.Agent({ keepAlive: false }) }, console.log);

And it will succeed.

What do you see instead?

Hang; the request succeeds and the response is given, but the process never exits.

Additional information

This is a change I saw in the Node 19 release blog post; keep-alive is enabled by default now, but, it seems to cause a hang.

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 by running the provided https.get reproduction on Node v19.8.1 and compare it with the keepAlive:false variant and Node 18. Trace the https request and agent lifecycle to determine why a successful HEAD response keeps the process alive. Done means the default keep-alive behavior no longer leaves this process hanging, with coverage for the reported reproduction.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
backend, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.