Prebid.js icon indicating copy to clipboard operation
Prebid.js copied to clipboard

Uncaught TypeError: Cannot read property 'map' of undefined

Open spormeon opened this issue 7 years ago • 13 comments

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)

spormeon avatar Jul 29 '19 18:07 spormeon

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

snapwich avatar Jul 29 '19 19:07 snapwich

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

spormeon avatar Jul 29 '19 19:07 spormeon

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

snapwich avatar Jul 29 '19 20:07 snapwich

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

spormeon avatar Jul 29 '19 20:07 spormeon

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.

snapwich avatar Jul 29 '19 20:07 snapwich

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

spormeon avatar Jul 29 '19 20:07 spormeon

@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?

curlyblueeagle avatar Jul 30 '19 13:07 curlyblueeagle

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.

snapwich avatar Jul 30 '19 15:07 snapwich

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

curlyblueeagle avatar Jul 31 '19 14:07 curlyblueeagle

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

curlyblueeagle avatar Jul 31 '19 14:07 curlyblueeagle

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

thomas-33across avatar Aug 05 '19 14:08 thomas-33across

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

spormeon avatar Aug 05 '19 14:08 spormeon

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.

stale[bot] avatar Aug 19 '19 15:08 stale[bot]