From 074c4ffa1e4631f6ccfcf5afdb40b7503c170ef9 Mon Sep 17 00:00:00 2001 From: Demetrio Girardi Date: Mon, 13 Dec 2021 06:44:19 -0800 Subject: [PATCH] Consent management module: allow auction to continue when CMP does not respond (#7769) This reproduces the behavior of `allowAuctionWithoutConsent` when a TCFv2 CMP times out. https://github.com/prebid/Prebid.js/issues/7156 --- modules/consentManagement.js | 8 +++++++- test/spec/modules/consentManagement_spec.js | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/modules/consentManagement.js b/modules/consentManagement.js index 65ffc9a4def8..ecd0c0eec4bf 100644 --- a/modules/consentManagement.js +++ b/modules/consentManagement.js @@ -371,7 +371,13 @@ function processCmpData(consentObject, hookConfig) { * General timeout callback when interacting with CMP takes too long. */ function cmpTimedOut(hookConfig) { - cmpFailed('CMP workflow exceeded timeout threshold.', hookConfig); + if (cmpVersion === 2) { + logWarn(`No response from CMP, continuing auction...`) + storeConsentData(undefined); + exitModule(null, hookConfig) + } else { + cmpFailed('CMP workflow exceeded timeout threshold.', hookConfig); + } } /** diff --git a/test/spec/modules/consentManagement_spec.js b/test/spec/modules/consentManagement_spec.js index 5e9b0f07f464..d7ae3c58a85b 100644 --- a/test/spec/modules/consentManagement_spec.js +++ b/test/spec/modules/consentManagement_spec.js @@ -715,6 +715,26 @@ describe('consentManagement', function () { expect(consent).to.be.null; }); + it('allows the auction when CMP is unresponsive', (done) => { + setConsentConfig({ + cmpApi: 'iab', + timeout: 10, + defaultGdprScope: true + }); + + requestBidsHook(() => { + didHookReturn = true; + }, {}); + + setTimeout(() => { + expect(didHookReturn).to.be.true; + const consent = gdprDataHandler.getConsentData(); + expect(consent.gdprApplies).to.be.true; + expect(consent.consentString).to.be.undefined; + done(); + }, 20); + }); + it('It still considers it a valid cmp response if gdprApplies is not a boolean', function () { // gdprApplies is undefined, should just still store consent response but use whatever defaultGdprScope was let testConsentData = {