-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(tracing): ignore the xhr/fetch response if its request is not being tracked #4428
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
Changes from 4 commits
e0137ef
c2e870c
d788c70
3993dd3
ccecb71
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -376,6 +376,7 @@ describe('Hub', () => { | |||||||||||||||
|
||||||||||||||||
const request = new XMLHttpRequest(); | ||||||||||||||||
request.open('GET', '/chase-partners'); | ||||||||||||||||
request.send(); | ||||||||||||||||
|
||||||||||||||||
// mock a response having been received successfully (we have to do it in this roundabout way because readyState | ||||||||||||||||
// is readonly and changing it doesn't trigger a readystatechange event) | ||||||||||||||||
|
@@ -418,6 +419,7 @@ describe('Hub', () => { | |||||||||||||||
|
||||||||||||||||
const request = new XMLHttpRequest(); | ||||||||||||||||
request.open('GET', '/chase-partners'); | ||||||||||||||||
request.send(); | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This errors because we are now actually making the request, to a resource that doesn't exist. As a quick thing to unblock we can just request sentry-javascript/packages/browser/test/unit/transports/xhr.test.ts Lines 18 to 24 in caba96e
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh somehow the tests did not fail on my machine. They do fail when I disable the Internet. I'm working on this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could not get the tests to work properly with fake servers. But since these tests do not really care about the responses, I have fixed them by waiting for the requests to complete regardless of the result |
||||||||||||||||
|
||||||||||||||||
// mock a response having been received successfully (we have to do it in this roundabout way because readyState | ||||||||||||||||
// is readonly and changing it doesn't trigger a readystatechange event) | ||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we probably want this logic to be like:
This is also more bundle size efficient
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi, thanks for looking into this.
I have refactored into using the
spanId
variable as suggested.But I'm using eager-return style because it modifies less codes and I also believe multiple nesting levels is less readable. Not sure if it's significant to the bundle size?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well it's two
return
keywords rather than one (both of which can't be minified), but yeah the impact is probably minimal. We can leave it like this!