undici icon indicating copy to clipboard operation
undici copied to clipboard

Missing '\r\n' in last boundary of FormData

Open viwydev opened this issue 8 months ago • 4 comments

Bug Description

When we send a POST request containing a FormData with fetch, the server never responds (as if still waiting for data). We end up going into timeout.

Reproducible By

const form = new FormData(); form.append('hash', 'abc123deadbeef');

let timer:any ; const resp = Promise.race([ fetch('http://localhost:3000/api', { method: 'POST', body: form }), new Promise((_,rejection) => timer = setTimeout(rejection, 10000, exception)) ]).finally(() => clearTimeout(timer)) ;

Expected Behavior

The last boundary should end with a new line '\r\n' allowing the server to know that all data has been sent.

Logs & Screenshots

Image

Environment

Node v22.15.0

viwydev avatar May 06 '25 17:05 viwydev

Thanks for reporting!

Can you provide steps to reproduce? We often need a reproducible example, e.g. some code that allows someone else to recreate your problem by just copying and pasting it. If it involves more than a couple of different file, create a new repository on GitHub and add a link to that.

mcollina avatar May 06 '25 17:05 mcollina

this looks similar to https://github.com/nodejs/undici/commit/fdeccc23b510bda706f5b62921a72ecdc593bda4

KhafraDev avatar May 06 '25 19:05 KhafraDev

Indeed, it looks very similar... Apparently NodeJS version 22 LTS includes the version 6.9 of the library... Hence the persistence of the problem on my side.

viwydev avatar May 07 '25 12:05 viwydev

node -p "`node: ${process.version}, undici: ${process.versions.undici}`"
node: v22.15.0, undici: 6.21.2

It seems like the commit didn't make it into the v6.21.2 release

https://github.com/nodejs/undici/pull/4210

KhafraDev avatar May 12 '25 16:05 KhafraDev

We shipped it with 6.21.3

https://github.com/nodejs/undici/releases/tag/v6.21.3

Uzlopak avatar Aug 09 '25 14:08 Uzlopak