undici icon indicating copy to clipboard operation
undici copied to clipboard

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

Open Vexcited opened this issue 1 year ago • 27 comments

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

Vexcited avatar Jan 31 '24 12:01 Vexcited