Skip to content

Commit b39b5e2

Browse files
authored
Pass dispatcher options to global fetch (#653)
* Pass dispatcher options to global fetch * Pass down all args to base fetch
1 parent 740000d commit b39b5e2

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

sdk_contrib/fetch/lib/fetch_p.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ const enableCapture = function enableCapture(baseFetchFunction, requestClass, do
116116
const requestClone = request.clone();
117117
let response;
118118
try {
119-
response = await baseFetchFunction(requestClone);
119+
response = await baseFetchFunction(...args);
120120

121121
if (thisSubsegmentCallback) {
122122
thisSubsegmentCallback(subsegment, requestClone, response);

sdk_contrib/fetch/test/unit/fetch_p.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,17 @@ describe('Unit tests', function () {
339339
response.should.equal(stubValidResponse);
340340
});
341341

342+
it('resolves to response through proxy when fetch options are supplied', async function() {
343+
const activeFetch = captureFetch(true);
344+
const proxyStub = sinon.stub();
345+
const request = new FetchRequest('https://www.foo.com/test');
346+
const response = await activeFetch(request, {
347+
dispatcher: proxyStub
348+
});
349+
stubFetch.should.have.been.calledOnceWith(request, {dispatcher: proxyStub});
350+
response.should.equal(stubValidResponse);
351+
});
352+
342353
it('calls subsegmentCallback with error upon fetch throwing', async function () {
343354
const spyCallback = sandbox.spy();
344355
const activeFetch = captureFetch(true, spyCallback);

0 commit comments

Comments
 (0)