-
Notifications
You must be signed in to change notification settings - Fork 15
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
'in' Filters with too many elements fail with "Uncaught RangeError" #7
Conversation
…aximum call stack size exceeded" Fixes mapbox/mapbox-gl-js#1782
How about something like: '[' + Array.prototype.slice.call(arguments, 2).map(function(value) {
return '(' + operators['=='](_, key, value) + ')';
}).join(',') + '].indexOf(true) >= 0' That would avoid the large disjunction for all cases. What it sacrifices in order to get that is short-circuit evaluation. |
Fixes mapbox/mapbox-gl-js#1782 If too many elements (varies by environment, but appx 1-2k) are used for an 'in' filter, it will fail with "Uncaught RangeError: Maximum call stack size exceeded". This is because the logical comparison of many infix comarisons (eg "(p['foo']==='bar') || (p['foo']==='cat') || ...") becomes too long for the v8natives to handle.
@jfirebaugh Love it! Passes my local tests (about 2k elements). Committed for Pull. |
👍 Can you add a test that triggers the |
Thinking about this more, we should preserve short-circuit evaluation too. '(function(){' + Array.prototype.slice.call(arguments, 2).map(function(value) {
return 'if (' + operators['=='](_, key, value) + ') return true;';
}).join('') + 'return false;})()'; |
Sorry can you elaborate on the range error issue?
|
Please add a test for this change, so we can ensure it doesn't regress with future changes. |
Oh, sure. I should be able to get to both of these later tonight.
|
@jfirebaugh ready to go |
Thanks! Committed as 6254b4c. I'll make a release and update the dependency in mapbox-gl-js shortly. |
👍 |
Fixes mapbox/mapbox-gl-js#1782
If too many elements (varies by environment, but appx 1-2k) are used for an 'in' filter, it will fail with "Uncaught RangeError: Maximum call stack size exceeded". This is because the logical comparison of many infix comarisons (eg "(p['foo']==='bar') || (p['foo']==='cat') || ...") becomes too long for the v8natives to handle.
Note: this fix does not handle large lists of VectorTileFeatureTypes.