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

Currency module: Don't block 'responsesReady' when rates are present and no conversion is done #10736

Merged

Conversation

samuel-palmer-relevant-digital
Copy link
Contributor

@samuel-palmer-relevant-digital samuel-palmer-relevant-digital commented Nov 16, 2023

Type of change

  • Bugfix

Description of change

This fix makes sure to not block the call to adapterDone() call in src/auction.js when the currency-module is being used with pbjs.setConfig({ currency: { rates: { ... }, ... } }) when there are no currency-conversions necessary in the auction.

The issue as that adapterDone() is never called by the following code in src/auction.js under these conditions - as the finally-callback is never executed:

responsesReady(GreedyPromise.resolve()).finally(() => adapterDone.call(this));

The reason is that responseReady.resolve() is never called in modules/currency.js as processBidResponseQueue() is not called when it's not necessary to fetch the currency-file and there is no bid-response with a currency that differs from the adServerCurrency.

Example

The code below delays the bidBackHandler for ~3 seconds (the timeout) because of the bug. With the fix the extra delay disappears.

<script src="https://cdn.jsdelivr.net/npm/prebid.js@latest/dist/not-for-prod/prebid.js"></script>
<h3 id="message">Loading...<h3>
<iframe id="example" scrolling="no" frameborder="0"></iframe>
<script>
    pbjs.addAdUnits([
        {
            code: 'example',
            mediaTypes: { banner: { sizes: [[300, 250]] } },
            bids: [{
                bidder: 'pubmatic',
                params: { publisherId: '45710', adSlot: '829342' },
            }]
        },
    ]);
    pbjs.setConfig({
        currency: {
            adServerCurrency: 'USD', // Change to 'SEK' will remove delay
            rates: { SEK: { USD: 0.1 } }
        },
    });
    const start = new Date();
    pbjs.requestBids({
        bidsBackHandler: () => {
            const [bid] = pbjs.getHighestCpmBids('example');
            if (bid) {
                const doc = example.contentDocument;
                message.innerHTML = `Ms until render: ${new Date() - start}<br>Ms to respond: ${bid.timeToRespond}`;
                pbjs.renderAd(doc, bid.adId);
                doc.body.style.margin = 0;
            }
        },
    });
</script>

@patmmccann patmmccann self-requested a review November 27, 2023 19:46
@patmmccann patmmccann merged commit 8993f74 into prebid:master Nov 27, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants