prebid / Prebid.js

Setup and manage header bidding advertising partners without writing code or confusing line items. Prebid.js is open source and free.
https://docs.prebid.org
Apache License 2.0
1.33k stars 2.08k forks source link

Uncaught TypeError: Cannot read property 'map' of undefined #4035

Closed spormeon closed 5 years ago

spormeon commented 5 years ago

started getting this in v 2.20 onwards, not a clue what it is: Uncaught TypeError: Cannot read property 'map' of undefined at Object.getUserSyncs (prebid2.25.0adyjs.js:4) at Object.p [as registerSyncs] (prebid2.25.0adyjs.js:3) at prebid2.25.0adyjs.js:26 at Array.forEach () at prebid2.25.0adyjs.js:26 at prebid2.25.0adyjs.js:26 at Object.success (prebid2.25.0adyjs.js:26) at XMLHttpRequest.onreadystatechange (prebid2.25.0adyjs.js:3)

snapwich commented 5 years ago

What bidders are you using? This is a specific error inside of a bid adapter.

spormeon commented 5 years ago

workspace-sts-3_8_3_RELEASE_-_Java_-_prebid-header-bidding_prebid_timhanlon_tweaktownhjgjhg756676_js_-_Spring_Tool_Suite

workspace-sts-3_8_3_RELEASE_-_Java_-_prebid-header-bidding_prebid_timhanlon_tweaktownhjgjhg756676_js_-_Spring_Tool_Suite-2

snapwich commented 5 years ago

Given those bidders I would have to guess the issue stems from the recent changes to the 33acrossBidAdapter in #3944

Specifically the unsafe access of adapterState.uniqueSiteIds.map here.

You can try removing that bidder to see if that fixes your issue.

cc: @curlyblueeagle

spormeon commented 5 years ago

ye, it was 33across, any fix for it?

actually the error is only there when using 33across S2S, bring it client side and the error goes away

snapwich commented 5 years ago

The immediate fix would probably be adding safe lookup to check for an undefined property, however the bug highlights a more serious code smell in that shared state is being stored outside buildRequests and getUserSyncs. This pattern could lead to unexpected behavior depending on run order (in this case I think you may be using prebid-server so buildRequests is never called since there are no client requests?) but also could cause edge case bugs around concurrent auctions.

The code should probably be refactored to only operate on function parameters instead of shared closure state. I cc'd @curlyblueeagle as this is a fix they'd probably have to make.

spormeon commented 5 years ago

ok, yes using prebid-server. One other odd thing noticed, is 33accross makes bids on S2S and is quite often the highest bidder but it never wins a bid or renderers an ad

curlyblueeagle commented 5 years ago

@snapwich we could fix the bug in the short-term by adding a safe lookup check. But we are forced to use shared state because we require parameters from all bid requests during user sync. I believe the utils library used to expose a method to obtain this during pre v1 days, but no longer. We tried to do user sync during interpretResponse #2024 , but that wasn't the ideal solution since we wanted to delink usersyncing from auction for the sake of performance. So we implemented the shared state in #2899.

Do you have a recommendation on how we can obtain params to bidrequests safely via a function?

snapwich commented 5 years ago

I believe most bidders return custom sync urls in their bid responses if they require custom sync data (beyond cookie data). You could do the same.

curlyblueeagle commented 5 years ago

copying @thomas-33across since he will be following up on this issue.

curlyblueeagle commented 5 years ago

hmm @thomas-33across says he is unable to add comment to this thread. Why?

thomas-33across commented 5 years ago

Hello @spormeon can you tell me your prebid.js setup page so I can try to reproduce the issue and make the code change? Thank you

spormeon commented 5 years ago

@thomas-33across unfortunately not, as its on test pages behind logins, where i test out new prebid releases not live sites

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.