You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the above example I would expect it to print out "421 endpoint response: This is a 421 Misdirected Request response." But instead it throws and it lands in the catch block. cURL, FireFox's and Chrome's implementation of fetch both have the expected behavior.
Because it only happens with request bodies of length 1 or greater, GET requests always work as expected
Logs & Screenshots
Error: TypeError: fetch failed
at node:internal/deps/undici/undici:12344:11
at async fetch421Endpoint (fourZeroSeven/fetch.js:38:22) {
cause: RequestContentLengthMismatchError: Request body length does not match content-length header
at AsyncWriter.end (node:internal/deps/undici/undici:9742:19)
at writeIterable (node:internal/deps/undici/undici:9646:16)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'UND_ERR_REQ_CONTENT_LENGTH_MISMATCH'
}
}
Environment
I have tried on the following node version: v18.18.0 and v21.6.1
Ubuntu 23.10
Bug Description
If the client sends a request with a body of length greater than 0 and the server responds with a 421 status then fetch will fail.
Reproducible By
With an express server (for example) with an endpoint like this
Being hit with fetch like this
Expected Behavior
In the above example I would expect it to print out "421 endpoint response: This is a 421 Misdirected Request response." But instead it throws and it lands in the catch block. cURL, FireFox's and Chrome's implementation of fetch both have the expected behavior.
Because it only happens with request bodies of length 1 or greater, GET requests always work as expected
Logs & Screenshots
Environment
I have tried on the following node version: v18.18.0 and v21.6.1
Ubuntu 23.10
Additional context
Additional information and a full server and client reproduction can be found here https://github.com/demergent-labs/fourZeroSeven
The text was updated successfully, but these errors were encountered: