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

fix(js): add concurrent modification case to "invalid array length" error page #32716

Merged
merged 2 commits into from
May 31, 2024

Conversation

OnkarRuikar
Copy link
Contributor

The exception is also thrown when array length is changed in a same for loop.

Tested on Google Chrome and Brave.

@OnkarRuikar OnkarRuikar requested a review from a team as a code owner March 18, 2024 05:55
@OnkarRuikar OnkarRuikar requested review from Josh-Cena and removed request for a team March 18, 2024 05:55
@github-actions github-actions bot added Content:JS JavaScript docs size/s [PR only] 6-50 LoC changed labels Mar 18, 2024
Copy link
Contributor

github-actions bot commented Mar 18, 2024

Copy link
Member

@Josh-Cena Josh-Cena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be fixed like this:

  • The condition for this error is one and unique: at any time, creating or growing an array to an invalid size. This has 3 sub cases: negative, non-integer, or too big. Negative and non-integer lengths are only achievable by directly setting length or using the constructor, because array methods avoid producing such length values. However, array methods can produce out of bounds lengths, such as pushing to a maxed array, or concating two such arrays. I think it should mention "using a growing array method and producing an array that's too long" as the underlying cause, instead of "concurrent modification", and you should merge it with the other "too big" case.
  • "Concurrent modification" in itself does not lead to anything bad. It's because you are doing this endlessly. The current example description is confusing

@farhadfarahi609
Copy link

Fix and close all

@farhadfarahi609
Copy link

Merging can be performed automatically once the requested changes are addressed.

@Josh-Cena Josh-Cena merged commit f4f0e36 into mdn:main May 31, 2024
8 checks passed
@OnkarRuikar OnkarRuikar deleted the patch-3 branch June 1, 2024 01:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:JS JavaScript docs size/s [PR only] 6-50 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants