Skip to content

Commit

Permalink
Separate ajax for client side and s2s requests (prebid#2735)
Browse files Browse the repository at this point in the history
* bugfix: separate ajax for client side and s2s requests

* Fix lint error
  • Loading branch information
jaiminpanchal27 authored and dluxemburg committed Jul 17, 2018
1 parent 1780444 commit f664a35
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/adaptermanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,14 +279,13 @@ exports.callBids = (adUnits, bidRequests, addBidResponse, doneCb) => {
return;
}

let ajax = ajaxBuilder(bidRequests[0].timeout);

let [clientBidRequests, serverBidRequests] = bidRequests.reduce((partitions, bidRequest) => {
partitions[Number(typeof bidRequest.src !== 'undefined' && bidRequest.src === CONSTANTS.S2S.SRC)].push(bidRequest);
return partitions;
}, [[], []]);

if (serverBidRequests.length) {
const s2sAjax = ajaxBuilder(serverBidRequests[0].timeout);
let adaptersServerSide = _s2sConfig.bidders;
const s2sAdapter = _bidderRegistry[_s2sConfig.adapter];
let tid = serverBidRequests[0].tid;
Expand Down Expand Up @@ -331,12 +330,13 @@ exports.callBids = (adUnits, bidRequests, addBidResponse, doneCb) => {
serverBidRequests,
addBidResponse,
() => doneCbs.forEach(done => done()),
ajax
s2sAjax
);
}
}
}

const ajax = (clientBidRequests.length) ? ajaxBuilder(clientBidRequests[0].timeout) : null;
// handle client adapter requests
clientBidRequests.forEach(bidRequest => {
bidRequest.start = timestamp();
Expand Down
3 changes: 3 additions & 0 deletions test/spec/unit/core/adapterManager_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ describe('adapterManager tests', () => {
'auctionId': '1863e370099523',
'bidderRequestId': '2946b569352ef2',
'tid': '34566b569352ef2',
'timeout': 1000,
'src': 's2s',
'adUnitsS2SCopy': [
{
Expand Down Expand Up @@ -315,6 +316,7 @@ describe('adapterManager tests', () => {
'bidderRequestId': '2946b569352ef2',
'tid': '34566b569352ef2',
'src': 's2s',
'timeout': 1000,
'adUnitsS2SCopy': [
{
'code': '/19968336/header-bid-tag1',
Expand Down Expand Up @@ -444,6 +446,7 @@ describe('adapterManager tests', () => {
],
'start': 1462918897460
}];

AdapterManager.callBids(
adUnits,
bidRequests,
Expand Down

0 comments on commit f664a35

Please sign in to comment.