$.map() fails with large arrays in Сhrome #4320
When a large array is passed as an argument to
Tested on Chrome 72 for Windows.
$.map(new Array(300000), i => 1)
Internally it calls to
As long as I understand,
I believe that any function being invoked thru
I've found about 14 usages of
The text was updated successfully, but these errors were encountered:
In an earlier ticket you mentioned that this happened with a templating library. Instead of processing one big template perhaps you could process multiple templates in groups.
Well, in fact I've just got an error with 130,000 items...
Why do you think that it is uncommon? Someone could develop an intranet business application that work with large tables. A table easily could have about 6,500 rows with 10 columns, So you've got 65,000 cells. Each cell could contain two
Anyway, the documentation doesn't mention about any limitations. The function
It was not my ticket.
I'm concerned that the problem is general for jQuery since it uses
Nobody should be rendering 6,500 rows on a page simultaneously. That is a good case for pagination or other segmentation techniques like a virtual scrolling window.
There are certainly occasional tickets where people hit these limits in jQuery, but as far as I can recall they have all been in this category of use cases that are unsupported and/or inadvisable.
It's not a limitation in jQuery, it's in Chrome. Firefox works up to at least 500,000. There's got to be a limit somewhere and using a design that hits a rarely-hit limit probably means you're pushing the limits in inadvisable ways.
I wouldn't be opposed to using native
This wouldn't help in IE (and Edge, but that will change soon) by default but:
I'll reopen so that we can discuss it a little more.
Calling `Array.prototype.concat.apply( , inputArray )` to flatten `inputArray` crashes for large arrays; using `Array.prototype.flat` avoids these issues in browsers that support it. In case it's necessary to support these large arrays even in older browsers, a polyfill for `Array.prototype.flat` can be loaded. This is already being done by many applications. (cherry picked from 9df4f1d) Fixes jquerygh-4320 Closes jquerygh-4459