Skip to content

Commit

Permalink
consentManagementGpp: fix handling of CMP errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dgirardi committed Dec 8, 2023
1 parent 4f3826a commit 95084ed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions modules/consentManagementGpp.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,18 @@ export class GPPClient {
* - a promise to GPP data.
*/
static init(mkCmp = cmpClient) {
if (this.INST == null) {
this.INST = this.ping(mkCmp).catch(e => {
this.INST = null;
let inst = this.INST;
if (!inst) {
let err;
const reset = () => err && (this.INST = null);
inst = this.INST = this.ping(mkCmp).catch(e => {
err = true;
reset();
throw e;
});
reset();
}
return this.INST.then(([client, pingData]) => [
return inst.then(([client, pingData]) => [
client,
client.initialized ? client.refresh() : client.init(pingData)
]);
Expand Down
2 changes: 1 addition & 1 deletion test/spec/modules/consentManagementGpp_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ describe('consentManagementGpp', function () {
});

it('should not re-use errors', (done) => {
cmpResult = Promise.reject(new Error());
cmpResult = GreedyPromise.reject(new Error());
GPPClient.init(makeCmp).catch(() => {
cmpResult = {signalStatus: 'ready'};
return GPPClient.init(makeCmp).then(([client]) => {
Expand Down

0 comments on commit 95084ed

Please sign in to comment.