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

Node HTTP integration missing protocol in breadcrumbs #3948

Closed
1 task done
thomaspurchas opened this issue Sep 1, 2021 · 0 comments · Fixed by #3950
Closed
1 task done

Node HTTP integration missing protocol in breadcrumbs #3948

thomaspurchas opened this issue Sep 1, 2021 · 0 comments · Fixed by #3950

Comments

@thomaspurchas
Copy link
Contributor

thomaspurchas commented Sep 1, 2021

Package + Version

  • @sentry/node

Version:

16.12.0

Description

The node HTTP integration occasionally misses the protocol from URL when it does argument normalisation. This is issue is caused by assuming that the arguments passed to http.request or https.request will always contain a protocol. However when making direct calls to https.request and http.request the protocol argument is optional, with the protocol default being set by the class being called.

A number of libraries seem to make use of this feature including Microsoft's Application Insights and the deprecated request library. The end result is requests originating from libraries like this end up with their protocols striped and invalid URL's being created (according to the WHATWG URL API).

The fix would be make the wrapper functions support the default values for the protocol argument, and better match the underlying Node API. I think a possible approach to extract the default protocol is to look a the modules globalAgent or the agent passed in the arguments done before extractUrl is called, something like:

if (requestArgs.protocol === undefined) {
  let protocol = this.globalAgent.protocol;
  if (requestArgs.agent instanceof this.Agent) {
    protocol = requestArgs.agent.protocol || ''
  } else if (requestArgs.agent === false) {
    protocol = new this.Agent().protocol
  }
  requestArgs.protocol = protocol
}

Screenshot 2021-09-01 at 10 15 26

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants