nodejs / undici

An HTTP/1.1 client, written from scratch for Node.js
https://nodejs.github.io/undici
MIT License
6.3k stars 550 forks source link

V7 onBodySent hook #3884

Open artur-ma opened 4 days ago

artur-ma commented 4 days ago

I see onBodySent hook was removed here https://github.com/nodejs/undici/pull/3878

We use the onBodySent hook, we use it to "await" the request until the data was sent on the socket, then we just resolve the promise while handling the request in the background, with some fallback to queue in case request fails.

This is useful if u have to make sure data transfer completed, and u assume that in most of the cases it will be handled successfully(with some fallback if not), and we do not really care on awaiting data processing on the other side. Looks like it is impossible to implement it now in V7.

Is it removed completely or there are plans to bing it back at some point?

ronag commented 4 days ago

There is some plans to add request hooks. But nothing I have time to look into atm. You can achieve the same behavior by wrapping the body in a stream and waiting for the 'end' event.