Skip to content
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

http plugin mark all http.request spans as error #1953

Closed
Grmiade opened this issue Mar 31, 2022 · 11 comments · Fixed by #1956
Closed

http plugin mark all http.request spans as error #1953

Grmiade opened this issue Mar 31, 2022 · 11 comments · Fixed by #1956
Labels
bug Something isn't working
Milestone

Comments

@Grmiade
Copy link

Grmiade commented Mar 31, 2022

Describe the bug
When our service receives an http response with a 200 status code. The span is marked as an error.
We have this issue since we upgraded to the 2.4.1 version, for all services and each http.request spans.

Screenshot 2022-03-31 at 10 20 19

Environment

  • Node version: 17.8.0
  • Tracer version: 2.4.1
@Grmiade Grmiade added the bug Something isn't working label Mar 31, 2022
@jakst
Copy link

jakst commented Mar 31, 2022

We're also seeing this from the v2.4.1 upgrade (we came from v2.2.0)

@rochdev
Copy link
Member

rochdev commented Mar 31, 2022

We did made a few changes to the http integration in that version, but I can't find anything obvious that would cause this and was unable to reproduce this locally. Can you share a reproduction snippet?

@iainmcgin
Copy link

iainmcgin commented Mar 31, 2022

We (Gusto) were just impacted by this too - upgrading from 2.4.0 to 2.4.1 in our graphql gateway service resulted in all outgoing POST requests being marked as errors. After rolling back to 2.4.0, the errors subsided. GET requests were unaffected.

Screen Shot 2022-03-31 at 11 45 19 AM

@rochdev
Copy link
Member

rochdev commented Mar 31, 2022

@iainmcgin Just tried with a POST request and still not getting the error flag set to 1. Are you using a specific client or http directly? Can you share how it's used?

@iainmcgin
Copy link

Our graphql gateway is built using apollo-server, and the requests occur within the context of a RemoteGraphQLDataSource. I don't think we've customized the fetcher, and it looks like the default implementation uses make-fetch-happen, and from our lock file, looks like v8.0.14. I hope that helps!

@Grmiade
Copy link
Author

Grmiade commented Mar 31, 2022

@rochdev It seems the problem comes from the instrumentation.
asyncEndClientCh.publish is executed multiple times (response + close)
The close event is always called during a successful request. So this line will be executed since no third parameter is provided here. What do you think?

See https://nodejs.org/api/http.html#:~:text=In%20a%20successful,%27close%27

In a successful request, the following events will be emitted in the following order:

  • 'socket'
  • 'response'
    • 'data' any number of times, on the res object ('data' will not be emitted at all if the response body is empty, for instance, in most redirects)
    • 'end' on the res object
  • 'close'

@Grmiade
Copy link
Author

Grmiade commented Mar 31, 2022

Moreover are you sure of this?

const finished = false
const finish = (finished, req, res) => {
  if (!finished) {
    finished = true // <|=====
    asyncEndClientCh.publish({ req, res })
  }
}

It seems you are reassigning the finished argument of the finish function and not the finished variable defined above.

@mb21
Copy link

mb21 commented Apr 1, 2022

We also have this after upgrading from 2.2.0 to 2.4.1 and we're using node-fetch 2.6.7 on node.js 16.13.

@rochdev
Copy link
Member

rochdev commented Apr 1, 2022

@Grmiade That's definitely it. I'll figure out a test and release a fix as soon as possible.

@bcomnes
Copy link

bcomnes commented May 23, 2022

Seeing this still, but only for HEAD requests in spans. They do not contain errors, but DD-trace is treating them as errors.

Rolling back to 2.4.0, this issue appears to gone, though HEAD request spans just totally disappear from spans... which I guess would hide the issue.

EDIT: opened an issue #2089

@tommoor
Copy link
Contributor

tommoor commented Dec 31, 2022

I'm still seeing this problem with the latest version 3.9.3 – is it possible something regressed here? 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants