Skip to content

Commit

Permalink
PBS adapter: log and trigger BIDDER_ERROR events on server errors (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
dgirardi authored Sep 14, 2023
1 parent 294b84e commit 6438f27
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 5 additions & 1 deletion modules/prebidServerBidAdapter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,11 @@ export function PrebidServer() {
done();
doClientSideSyncs(requestedBidders, gdprConsent, uspConsent, gppConsent);
},
onError: done,
onError(msg, error) {
logError(`Prebid server call failed: '${msg}'`, error);
bidRequests.forEach(bidderRequest => events.emit(CONSTANTS.EVENTS.BIDDER_ERROR, {error, bidderRequest}));
done();
},
onBid: function ({adUnit, bid}) {
const metrics = bid.metrics = s2sBidRequest.metrics.fork().renameWith();
metrics.checkpoint('addBidResponse');
Expand Down
9 changes: 9 additions & 0 deletions test/spec/modules/prebidServerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2876,6 +2876,15 @@ describe('S2S Adapter', function () {
events.emit.restore();
});

it('triggers BIDDER_ERROR on server error', () => {
config.setConfig({ s2sConfig: CONFIG });
adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax);
server.requests[0].respond(400, {}, {});
BID_REQUESTS.forEach(bidderRequest => {
sinon.assert.calledWith(events.emit, CONSTANTS.EVENTS.BIDDER_ERROR, sinon.match({bidderRequest}))
})
})

// TODO: test dependent on pbjs_api_spec. Needs to be isolated
it('does not call addBidResponse and calls done when ad unit not set', function () {
config.setConfig({ s2sConfig: CONFIG });
Expand Down

0 comments on commit 6438f27

Please sign in to comment.