Skip to content

'cancelled' http.client spans due to Xhr responses being falsely reported as requests #4427

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

Closed
6 of 9 tasks
datbth opened this issue Jan 20, 2022 · 3 comments
Closed
6 of 9 tasks

Comments

@datbth
Copy link
Contributor

datbth commented Jan 20, 2022

Package + Version

  • @sentry/browser
  • @sentry/node
  • raven-js
  • raven-node (raven for node)
  • other: @sentry/vue, @sentry/tracing

Version:

6.16.1

Description

http.client spans get marked as 'cancelled' due to Xhr responses being falsely reported as requests.

Setup:

  • Use vueRouterInstrumentation
  • Make some xhr requests before Vue routing happens (i.e. before 'pageload' transaction has even started).

Actual result:

  • If the responses (of the before-vue-routing requests) return after Vue routing, they are recognized as new spans.
    Consequently, these spans never receive any further update and eventually get marked as 'cancelled'

Expected result:

  • The responses (of the before-vue-routing requests) get discarded?

Troubleshooting:

  • For every xhr request, xhrCallBack is called two times:
    1. When the request is created, to start the http.client span
    2. When the request is completed, to finish the http.client span
  • However, in the first call, Vue routing has not happened and hence instrumentation has not started the 'pageload' transaction yet. Thus, the execution is halted and the http.client span is not properly initialized. Then, in the second call, handlerData.xhr.__sentry_xhr_span_id__ is not available, so the xhr request completion is mistaken as a new request creation.

Possible fix

Update 1

  • fetch also has the similar issue
@datbth datbth changed the title 'cancelled' http.client spans due to Xhr **responses** being mistakenly reported as **requests** 'cancelled' http.client spans due to Xhr responses being mistakenly reported as requests Jan 20, 2022
@datbth datbth changed the title 'cancelled' http.client spans due to Xhr responses being mistakenly reported as requests 'cancelled' http.client spans due to Xhr responses being falsely reported as requests Jan 20, 2022
@datbth
Copy link
Contributor Author

datbth commented Jan 21, 2022

I wonder if it makes sense and is possible to somehow track the requests that happen before Vue routing? After all, the transaction is 'pageload' so I think it should track everything from the moment user opens the page, not just after Vue routing has started?

@datbth
Copy link
Contributor Author

datbth commented Jan 24, 2022

I just found out many events on my app were missed because my app failed to properly wait for Vue router.isReady.
There are probably still some valid use cases for sending requests before Vue router is fully initialized, but hopefully this comment is still helpful for others stumbling across this issue.

@AbhiPrasad
Copy link
Member

#4531 will also help further address this, but if there's anything else that comes up, please let us know!

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

No branches or pull requests

2 participants