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

return a promise from requestBids causes issues along with criteoId #9191

Closed
muuki88 opened this issue Nov 2, 2022 · 3 comments · Fixed by #9194
Closed

return a promise from requestBids causes issues along with criteoId #9191

muuki88 opened this issue Nov 2, 2022 · 3 comments · Fixed by #9194
Assignees

Comments

@muuki88
Copy link
Collaborator

muuki88 commented Nov 2, 2022

Type of issue

prebid.js crashes while starting a second auction, because adUnits is undefined.
This only happens when the criteoIdSystem is part of the prebid.js distribution.

Description

Upgrading to 7.23.0 and having the criteoIdSystem active causes prebid.js to crash with

prebid.js:237 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'forEach')
    at prebid.js:237:11
    at order.<computed> (index.js:342:1)
    at next (index.js:328:1)
    at preloadBidderMappingFile (bidderFactory.js:476:15)
    at next (index.js:328:1)
    at Object.trap [as apply] (index.js:347:1)
    at prebid.js:651:75
    at Object.measureTime (perfMetrics.js:127:16)
    at prebid.js:651:33
    at order.<computed> (index.js:342:1)

I suspect that there's an issue with #9106 as the hook is now sync and not async (also I do not know what this implies).

While trying to build a minimal example, I figured that removing criteoIdSystem fixed this issue.
Now I'm really puzzled as I thought #9106 may introduced this, but I have no idea why the criteoIdSystem changes this behaviour as well.

Steps to reproduce

Run an "ad pipeline" (or auction pipeline) for a set of ad units.

  1. Call pbjs.addAdUnits for the specified adUnits
  2. Call bjs.requestBids({ adUnitCodes: adUnitCodes, timeout: ..., bidsBackHandler => /* do the gpt targeting stuff */

Test page

https://frag-muki.de/prebid/bucket-issue/

Expected results

No Crash

Actual results

Crash

Platform details

  • prebid 7.23.0

Other information

@dgirardi dgirardi self-assigned this Nov 2, 2022
@dgirardi
Copy link
Collaborator

dgirardi commented Nov 2, 2022

@muuki88, I see the issue on your test page but I'm having trouble isolating it. Would you be able to build it with unminifed Prebid? Or alternatively, if you can confirm that reverting #9106 fixes it, we can roll that back as a first step.

I am not able to reproduce locally using this test page:
This test page reproduces locally:

<!--
  This page calls a single bidder for a single ad slot. It can be considered a "hello world" example for using
  Prebid with the Google Publisher Tag.
  It also makes a good test page for new adapter PR submissions. Simply set your server's Bid Params object in the
  bids array inside the adUnits, and it will use your adapter to load an ad.
  NOTE that many ad servers won't send back an ad if the URL is localhost... so you might need to
  set an alias in your /etc/hosts file so that you can load this page from a different domain.
-->

<html>
<head>
    <script async src="../../build/dev/prebid.js"></script>
    <script async src="https://www.googletagservices.com/tag/js/gpt.js"></script>
    <script>
        var FAILSAFE_TIMEOUT = 33000;
        var PREBID_TIMEOUT = 10000;

        var adUnits = [{
            code: 'au1',
            mediaTypes: {
                banner: {
                    sizes: [[300, 250], [300, 600]],
                }
            },
            // Replace this object to test a new Adapter!
            bids: [{
                bidder: 'adplus',
                params: {
                    inventoryId: '-1',
                    adUnitId: '-3',
                },
            },
                {
                    bidder: "rubicon",
                    params: {
                        accountId: 14062,
                        siteId: 70608,
                        zoneId: 498816
                    }
                }

            ]

        }, {
            code: 'au2',
            mediaTypes: {
                banner: {
                    sizes: [[300, 250], [300, 600]],
                }
            },
            // Replace this object to test a new Adapter!
            bids: [{
                bidder: 'adplus',
                params: {
                    inventoryId: '-1',
                    adUnitId: '-3',
                },
            },
                {
                    bidder: "rubicon",
                    params: {
                        accountId: 14062,
                        siteId: 70608,
                        zoneId: 498816
                    }
                }

            ]

        }];

        var pbjs = pbjs || {};
        pbjs.que = pbjs.que || [];
        pbjs.bidderSettings = {
            standard: {
                storageAllowed: true
            }
        }
        let tcStr = 'CO4EXq8O4EYOWADABCDEAxCsAP_AAH_AAAAAGStV_T9fb2vj-_599_t0eY1f9_63t-wzhheMs-8NyZeX_J4Wv2MyvB34JqQKGRgkunLBAQdtHGncTQgBwIlViTLMYk2MjzNKJrJEmlsbO2dYGH9Pn8XT_ZKZ70-vv__7v3___33_4GSEEmCpfAQJCWMBJNmlUKIEIVxIVAOASghGEg0sNCRQU7I4CPUACABAYAIQIAQAgohJBAAIAAElEQAgAwIBEARAIAAQAjQEIACJAEFgBIGAQACoGhYARRBKBIQYHBUcogQFSLRQTwCQgAAMAAEAABQAAYAAHAACAAAkAAKAAA.YAAAAAAAAAA'

        var pbjs = pbjs || {};
        pbjs.que = pbjs.que || [];
        pbjs.que.push(function() {
            pbjs.setConfig({
                debug: true,
            })
            pbjs.setConfig({
                priceGranularity: "high",
                userSync: {
                    "syncEnabled": true,
                    "filterSettings": {
                        "iframe": {
                            "bidders": "*",
                            "filter": "include"
                        },
                        "image": {
                            "bidders": "*",
                            "filter": "include"
                        }
                    },
                    "syncsPerBidder": 1,
                    "syncDelay": 6e3,
                    "auctionDelay": 50,
                    "aliasSyncEnabled": true,
                    "enableOverride": true,
                    "ppid": "pubcid.org",
                    "userIds": [{
                        name: "unifiedId",
                        params: {
                            partner: "732jplk"
                        },
                        storage: {
                            type: "html5",
                            name: "pbjs-unifiedid",
                            expires: 60
                        }
                    }, {
                        name: "criteo"
                    }, {
                        name: "id5Id",
                        params: {
                            partner: 435
                        },
                        storage: {
                            type: "html5",
                            name: "id5id",
                            expires: 90,
                            refreshInSeconds: 28800
                        }
                    }],
                    "encryptedSignalSources": {
                        "sources": [
                            {
                                "source": [
                                    "adserver.org",
                                    "criteo.com",
                                    "id5-sync.com",
                                    "pubcid.org"
                                ],
                                "encrypt": false
                            }
                        ],
                        "registerDelay": 2000
                    }
                },
                consentManagement: {
                    gdpr: {
                        cmpApi: 'static',
                        consentData: {
                            getTCData: {
                                tcString: tcStr,
                                gdprApplies: true,
                                vendor: {
                                    consents: {
                                        52: true,
                                        91: true,
                                        131: true,
                                        21: true,
                                    }
                                },
                                purpose: {
                                    consents: {
                                        1: true,
                                        2: true,
                                        3: true,
                                        4: true,
                                        5: true,
                                        6: true,
                                        7: true,
                                        8: true,
                                        9: true,
                                        10: true
                                    }
                                }
                            }
                        }
                    }
                }
            });
        });
    </script>

    <script>
        var googletag = googletag || {};
        googletag.cmd = googletag.cmd || [];
        googletag.cmd.push(function () {
            googletag.pubads().disableInitialLoad();
        });

        pbjs.que.push(function () {
            pbjs.setConfig({
                debug: true,
            });
            pbjs.addAdUnits(adUnits);
            pbjs.requestBids({
                adUnitCodes: ['au1'],
                bidsBackHandler: sendAdserverRequest,
                timeout: PREBID_TIMEOUT
            });
            pbjs.requestBids({
                adUnitCodes: ['au2'],
                bidsBackHandler: sendAdserverRequest,
                timeout: PREBID_TIMEOUT
            });
        });

        function sendAdserverRequest() {
            googletag.cmd.push(function () {
                pbjs.que.push(function () {
                    pbjs.setTargetingForGPTAsync();
                    googletag.pubads().refresh();
                });
            });
        }

        setTimeout(function () {
            sendAdserverRequest();
        }, FAILSAFE_TIMEOUT);

    </script>

    <script>
        googletag.cmd.push(function () {
            googletag.defineSlot('/19968336/header-bid-tag-0', [[300, 250], [300, 600]], 'au1').setTargeting('safeframe', '1').addService(googletag.pubads());
            googletag.defineSlot('/19968336/header-bid-tag-1', [[300, 250], [300, 600]], 'au2').setTargeting('safeframe', '1').addService(googletag.pubads());

            googletag.enableServices();
        });
    </script>
</head>

<body>
<h2>Prebid.js Test</h2>
<h5>Div-1</h5>
<div id='au1'>
    <script type='text/javascript'>
        googletag.cmd.push(function () {
            googletag.display('au1');
        });
    </script>
</div>
<div id='au2'>
    <script type='text/javascript'>
        googletag.cmd.push(function () {
            googletag.display('au2');
        });
    </script>
</div>

</body>
</html>

@muuki88
Copy link
Collaborator Author

muuki88 commented Nov 2, 2022

Thanks for the immediate response 🤗

So it seems that this change broke multiple requestBid calls?

I'm not there the next couple of days to further confirm 😔

@dgirardi
Copy link
Collaborator

dgirardi commented Nov 2, 2022

It does look to be related to #9106 , although it appears to be an odd race condition that I expect will take some time to track down - I think it's best to revert for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants