nodejs / nodejs/undici

HPE_INVALID_CHUNK_SIZE but works without any issue in curl, browser and other runtimes excluding Node.js

Open
#2,678 31 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Bug Description

Whenever I run .text() or try to read the body, I get and HPE_INVALID_CHUNK_SIZE error on Node.js on every requests made to my University's VPN domain (u-vpn.unilim.fr)

Reproducible By

const response = await fetch("https://u-vpn.unilim.fr/remote/logincheck", {
  "headers": {
    "accept": "*/*",
    "cache-control": "no-store, no-cache, must-revalidate",
    "content-type": "text/plain;charset=UTF-8",
    "if-modified-since": "Sat, 1 Jan 2000 00:00:00 GMT",
    "pragma": "no-cache",
    "Referer": "https://u-vpn.unilim.fr/remote/login?lang=en",
    "Referrer-Policy": "strict-origin-when-cross-origin"
  },
  // Fake credentials, still throws the error though
  "body": "ajax=1&username=a&realm=&credential=b",
  "method": "POST"
});

// Only happens here.
console.log(await response.text());

Expected Behavior

Every other runtimes and browsers can give me the actual text response : ret=0,redir=/remote/login?&err=sslvpn_login_permission_denied&lang=en

Environment

Ubuntu 22.04 LTS,
Node v20.11.0

Additional context

I can still get the data by catching the error and doing error.cause.data but this data is truncated on long responses so not usable for me on further requests.

When I say other runtimes : Bun and Deno gives the response.

image
image

Only Node.js throws...

image

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

Run the provided Node.js v20.11.0 reproducer against u-vpn.unilim.fr and inspect the response-body path reached by response.text(). Compare its handling with the successful Bun, Deno, curl, and browser results. Done means the full response text is returned without HPE_INVALID_CHUNK_SIZE or truncation.

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
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.