opentelemetry-js icon indicating copy to clipboard operation
opentelemetry-js copied to clipboard

@opentelemetry/instrumentation-http crashes superagent

Open fredericosilva opened this issue 2 years ago • 2 comments

What version of OpenTelemetry are you using?

@opentelemetry/[email protected]
@opentelemetry/[email protected]
@opentelemetry/[email protected]
@opentelemetry/[email protected]

What version of Node are you using?

v16.15.1

What did you do?

const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node');
const { HttpInstrumentation } = require('@opentelemetry/instrumentation-http');
const { SimpleSpanProcessor, ConsoleSpanExporter } = require('@opentelemetry/sdk-trace-base');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');

const provider = new NodeTracerProvider();

provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
provider.register();

registerInstrumentations({
  instrumentations: [new HttpInstrumentation()],
});

require('superagent')
  .get('https://www.googleapis.com/oauth2/v3/certs')
  .then(rsp => console.log(rsp.body))
  .catch(console.error)
;

What did you expect to see?

No crash

What did you see instead?

Error: read ECONNRESET
    at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20)
    at TLSWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
  errno: -54,
  code: 'ECONNRESET',
  syscall: 'read',
  response: undefined
}
superagent: double callback bug

Additional context

Other requests work fine, there is something specific here that I'm not able to pinpoint. Any help is appreciated.

I did try using multiple superagent versions with the same result (v5, v6, v7 and v8)

I'm leaving here a raw request/response for future reference if it happens to start to work.

curl -v --http1.1 'https://www.googleapis.com/oauth2/v3/certs' > /dev/null

> GET /oauth2/v3/certs HTTP/1.1
> Host: www.googleapis.com
> User-Agent: curl/7.79.1
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Vary: X-Origin
< Vary: Referer
< Server: scaffolding on HTTPServer2
< X-XSS-Protection: 0
< X-Frame-Options: SAMEORIGIN
< X-Content-Type-Options: nosniff
< Date: Mon, 04 Jul 2022 16:03:19 GMT
< Expires: Mon, 04 Jul 2022 22:31:15 GMT
< Cache-Control: public, max-age=23276, must-revalidate, no-transform
< Content-Type: application/json; charset=UTF-8
< Age: 8
< Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
< Accept-Ranges: none
< Vary: Origin,Accept-Encoding
< Transfer-Encoding: chunked

fredericosilva avatar Jul 04 '22 16:07 fredericosilva

Tried with follwoing versions and I see no crash:

"@opentelemetry/instrumentation": "0.30.0",
"@opentelemetry/instrumentation-http": "0.30.0",
"@opentelemetry/sdk-trace-base": "1.4.0",
"@opentelemetry/sdk-trace-node": "1.4.0",
"superagent": "8.0.0"

Flarna avatar Jul 07 '22 15:07 Flarna

Thank you @Flarna

It only happens in a specific network+os configuration it seems, need to dig deeper.

fredericosilva avatar Aug 17 '22 11:08 fredericosilva

@fredericosilva any update on this?

dyladan avatar Sep 28 '22 16:09 dyladan

I had no time yet to try to understand what is going on, the problem still happens after updating to the latest:

├── @opentelemetry/[email protected]
├── @opentelemetry/[email protected]
├── @opentelemetry/[email protected]
├── @opentelemetry/[email protected]
└── [email protected]

I'm going to try to have a look on that during this week.

fredericosilva avatar Oct 04 '22 14:10 fredericosilva

Can you at least provide which network/os combo you used to reproduce this so that maybe someone with more time can take a look?

dyladan avatar Oct 05 '22 16:10 dyladan

@fredericosilva I was going to close this because I can't reproduce it but I want to see if you're still working on it first

dyladan avatar Nov 02 '22 16:11 dyladan

I can't reproduce right now. I'll close it and reopen when/if I have more information. Thank you

fredericosilva avatar Nov 03 '22 11:11 fredericosilva