-
Notifications
You must be signed in to change notification settings - Fork 2.3k
ixBidAdapter: avoid looping over all properties of the array #13703
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
ixBidAdapter: avoid looping over all properties of the array #13703
Conversation
Switch to an indexed for loop instead of a for...in loop to loop over the values contained in the array. Otherwise other properties of the array might be picked up, for example when somebody has adjusted the array prototype to for example add an average function on it.
Which one? |
|
Nothing prebid related. |
it is very surprising ix is the only problem you are experiencing |
|
We log a warning when we don't find a matching creative type, but there are likely many other places that iterate over arrays this way that don't log when there's a problem across the bidders. |
Well, it isn't really a problem as all that happens is that a warning gets logged. But each time I see that warning, I have to remember what is causing it and that it isn't a real issue.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration#arrays suggests that is not the way to iterate over an array, and an indexed for loop or the for...of is preferred. Mainly to avoid this exact problem. |
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.
LGTM
Type of change
Bugfix
Feature
New bidder adapter
Updated bidder adapter
Code style update (formatting, local variables)
Refactoring (no functional changes, no api changes)
Build related changes
CI related changes
Does this change affect user-facing APIs or examples documented on http://prebid.org?
Other
Description of change
Switched from a for...in loop to an indexed for loop in the ixBidAdapter to loop over the values in an array.
We got warnings like
The root cause is another JS library which is messing around with the
Arrayprototype, and adds additional functions on it. The for...in loop picks those up, and starts logging warnings.As there is no real reason to use a for...in loop to iterate over an array, I switched it to a regular indexed for loop which avoids the problem.
Other information