HTTP Instrumentation responseHook
breaks streams when used with axios
#5477
Labels
bug
Something isn't working
has:reproducer
This bug/feature has a minimal reproducer provided
triage
What happened?
The issue happens when using
@opentelemetry/instrumentation-http
with Axios streams (responseType: stream
) and the server sends the response as a single chunk. In this case, theresponse.on("data")
event is not triggered, and the single-chunk response is lost, disrupting the stream. This behavior does not occur when using the nativehttp
module orfetch
.Steps to Reproduce
This repo will help to reproduce the issue https://github.com/dinumihnea/opentelemetry-axios-stream-issue
The conditions to replicate the issue are very specific:
@opentelemetry/instrumentation-http responseHook
intercept theresponse.on("data")
eventresponseType
isstream
When these 3 conditions are met the single response chunk is lost.
I wasn't able to reproduce the issue when using native
http
module orfetch
.Expected Result
Streams to work even if they're intercepted by the
responseHook
Actual Result
Streams are disrupted when
instrumentation-http responseHook
is configured - theresponse.on("data")
listener is not invoked.Additional Details
res.prependListener("data", ...)
instead ofres.on("data", ...)
in theresponseHook
, however this doesn't seem right. This workaround suggests that the issue may be related to how the@opentelemetry/instrumentation-http
package manipulates the order of events.I hope this additional info is helpful.
OpenTelemetry Setup Code
package.json
Relevant log output
Operating System and Version
macOS 15.3 and Debian 12
Runtime and Version
Node
v22.13.0
andv20.18.1
The text was updated successfully, but these errors were encountered: