-
Notifications
You must be signed in to change notification settings - Fork 142
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
[RUMF-824] support Request instances in tracing #684
Conversation
a17434e
to
75ad984
Compare
75ad984
to
fb2165f
Compare
Codecov Report
@@ Coverage Diff @@
## master #684 +/- ##
==========================================
- Coverage 77.98% 77.85% -0.13%
==========================================
Files 60 60
Lines 3284 3288 +4
Branches 714 715 +1
==========================================
- Hits 2561 2560 -1
- Misses 723 728 +5
Continue to review full report at Codecov.
|
resolveWith and rejectWith don't need to be async, and they don't actually return anything (`resolve` and `reject` are returning 'undefined')
context.input.headers.forEach((value, key) => { | ||
headers.push([key, value]) | ||
}) | ||
} | ||
context.init.headers = headers.concat(objectEntries(tracingHeaders) as string[][]) |
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.
It seems a bit weird to me to not update input headers but to provide an init headers instead.
I am wondering if it could not be better to provide an updated input only:
context.input = new Request(request, {
headers: headers.concat(objectEntries(tracingHeaders) as string[][])
})
no strong argument for one or the other though.
wdyt?
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.
Mmh it seems to be equivalent, since calling fetch(input, init)
calls new Request(input, init)
internally. After a few tests, I think that it should be fine. I only spoted an issue with streaming requests but it is likely to be a Chrome bug in the ongoing implementation:
const request = new Request('/post', {
method: 'POST',
body: new ReadableStream(),
mode: 'cors'
});
// works:
await fetch(request, { mode: 'cors' })
// fails with: TypeError: Failed to construct 'Request': If request is made from ReadableStream, mode should be"same-origin" or "cors"
const requestCopy = new Request(request)
await fetch(requestCopy, { mode: 'cors' })
I think it's fine nonetheless, I updated the implementation, let me know if it looks better to you.
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.
👍
This reverts commit 3b3c12a.
Motivation
Support
Request
instances in tracingChanges
Clone instance and add trace headers if the fetch init argument is a
Request
.Testing
Unit
I have gone over the contributing documentation.