Skip to content
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

Separate ajax for client side and s2s requests #2735

Merged
merged 2 commits into from
Jun 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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