-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Prebid core: fix exception in requestBids
introduced by #9106
#9194
Conversation
This reverts commit 64aff9b.
Pr updated with an actual fix. |
requestBids
(#9106)"requestBids
introduced by #9106
4bfb136
to
f9c72fa
Compare
f9c72fa
to
58a35ae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this so fast @dgirardi 🤗
req.defer = defer({promiseFactory: (r) => new Promise(r)}) | ||
delegate.call(this, req); | ||
return req.defer.promise; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a few comments why this is necessary would be helpful.
As someone only looking at bid adapters mostly the fun-hook framework and the custom promise implementation this code is non-obivous why it's there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're asking about the reason for fun-hooks or the custom promise:
- fun-hooks is basically a plugin system (to the author: sorry if I'm oversimplifying this). if we have 5 modules that may be loaded in a random combination and order, and all plug into the same code path, fun-hook solves the problem of orchestrating those. I can't answer why we are using that over something else.
- the custom promise -
A version of Promise that runs callbacks synchronously when it can
- came about because of this discussion.
As for this code specifically, I tried clarifying it in the comments - it boils down to idiosyncrasies of fun-hooks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the clarification 🤗
@@ -1665,7 +1677,7 @@ describe('Unit: Prebid Module', function () { | |||
sinon.assert.match(bids[bid.adUnitCode].bids[0], bid) | |||
done(); | |||
}); | |||
completeAuction([bid]); | |||
setTimeout(() => completeAuction([bid])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also a small comment here why wrapping in setTimeout is required here
@@ -622,15 +623,15 @@ $$PREBID_GLOBAL$$.removeAdUnit = function (adUnitCode) { | |||
* @alias module:pbjs.requestBids | |||
*/ | |||
$$PREBID_GLOBAL$$.requestBids = (function() { | |||
const delegate = hook('sync', function ({ bidsBackHandler, timeout, adUnits, adUnitCodes, labels, auctionId, ttlBuffer, ortb2, metrics } = {}) { | |||
const delegate = hook('async', function ({ bidsBackHandler, timeout, adUnits, adUnitCodes, labels, auctionId, ttlBuffer, ortb2, metrics, defer } = {}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I discovered the issue a little more comments would have helped what the intention of this delegate
method was or what it is supposed to do.
…prebid#9194) * Revert "Prebid core: return a promise from `requestBids` (prebid#9106)" This reverts commit 64aff9b. * Revert "Revert "Prebid core: return a promise from `requestBids` (prebid#9106)"" This reverts commit bf5ee30. * Prebid core: fix exception in `requestBids` introduced by prebid#9106 * Add comments
…prebid#9194) * Revert "Prebid core: return a promise from `requestBids` (prebid#9106)" This reverts commit 64aff9b. * Revert "Revert "Prebid core: return a promise from `requestBids` (prebid#9106)"" This reverts commit bf5ee30. * Prebid core: fix exception in `requestBids` introduced by prebid#9106 * Add comments
…prebid#9194) * Revert "Prebid core: return a promise from `requestBids` (prebid#9106)" This reverts commit 64aff9b. * Revert "Revert "Prebid core: return a promise from `requestBids` (prebid#9106)"" This reverts commit bf5ee30. * Prebid core: fix exception in `requestBids` introduced by prebid#9106 * Add comments
Type of change
Description of change
Fix a bug introduced by #9106: if a module such as userId needs to delay the auction (
auctionDelay > 0
), it can cause hooks to run out of order and error out.Fixes #9191