-
Notifications
You must be signed in to change notification settings - Fork 560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add undici:body:consumed
diagnostics channel
#1369
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1369 +/- ##
==========================================
+ Coverage 94.25% 94.26% +0.01%
==========================================
Files 45 45
Lines 4211 4222 +11
==========================================
+ Hits 3969 3980 +11
Misses 242 242
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry but I don't like this. Can't you just have a event for each body chunk? and then trailers will signal end of body?
I can look into it, but this is also opt-in (rather than the old PR where it was added onto the trailers channel), and it only sends the body that was already consumed, rather than duplicating it. Also publishing a message for each chunk would make it very hard to group together correctly, since 2 requests to the same origin/path could be made at once. edit: also in the code I used import { request } from 'undici'
import { text } from 'stream/consumers'
const { body } = await request('...') // nothing is published
await body.text() // a message is published, identical to the value this method returned
await text(body) // no message published
for await (const chunk of body) {
// ...
}
// no message published |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, good work
I'm getting mixed signals here 😅 |
I have a feeling this could impact perf in the wrong way as that's a fairly hot path. Anyway if that does not regress the perf, it would be ok. |
I think this way is more convenient and faster. It also only requires 1 message rather than x amount of chunks received and doesn't require the user to parse the body themselves. |
Fixes #1342
Superseded #1344 with a slightly more reliable solution (relies on consuming via the body mixins).