[diagnostics_channel] support body received?
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 880
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 68
Description
This would solve...
In a library I am working on, they had 2 events (request & response) that would fire before and after a request was made. The purpose of these events was for analytics (ie. receiving a "weird" response code and checking the body). With undici, I'm hoping that these events can be removed entirely and instead use the diagnostics_channel support (the library only supports v16.9.0+).
The implementation should look like...
In the request property, the body is sent but under a symbol property and uncloned. Exposing it publicly (maybe under bodyReceived or some other name) and cloning it so it can be used twice would be exactly what I need. Receiving a buffer would also be very useful.
Since it is using request, rather than fetch, it is using a node Readable stream so we can't just tee the stream.
I have also considered...
Additional context
The implementation previously used was not performant and didn't need to be because it was only supposed to be used when something majorly messed up.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the diagnostics_channel request property and how the received body is currently stored as a symbol-backed, uncloned Node.js Readable stream. Define the public body representation and duplication behavior, then verify that diagnostics_channel consumers can inspect the body twice, including the requested buffer use case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100