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

Stack overflow calling SortedSet.toArray() #164

Open
royaldark opened this issue Oct 15, 2016 · 3 comments
Open

Stack overflow calling SortedSet.toArray() #164

royaldark opened this issue Oct 15, 2016 · 3 comments
Labels

Comments

@royaldark
Copy link

I have a SortedSet with 9904 entries (simple one-level maps). Calling .toArray() always throws a call stack exceeded error.

 RangeError: Maximum call stack size exceeded
    at Node.reduce (C:\cygwin64\home\Joe\dev\texts\node_modules\collections\sorted-set.js:584:34)
    at Node.reduce (C:\cygwin64\home\Joe\dev\texts\node_modules\collections\sorted-set.js:589:27)
    at Node.reduce (C:\cygwin64\home\Joe\dev\texts\node_modules\collections\sorted-set.js:589:27)
    at Node.reduce (C:\cygwin64\home\Joe\dev\texts\node_modules\collections\sorted-set.js:589:27)
    at Node.reduce (C:\cygwin64\home\Joe\dev\texts\node_modules\collections\sorted-set.js:589:27)
    at Node.reduce (C:\cygwin64\home\Joe\dev\texts\node_modules\collections\sorted-set.js:589:27)
    at Node.reduce (C:\cygwin64\home\Joe\dev\texts\node_modules\collections\sorted-set.js:589:27)
    at Node.reduce (C:\cygwin64\home\Joe\dev\texts\node_modules\collections\sorted-set.js:589:27)
    at Node.reduce (C:\cygwin64\home\Joe\dev\texts\node_modules\collections\sorted-set.js:589:27)
    at Node.reduce (C:\cygwin64\home\Joe\dev\texts\node_modules\collections\sorted-set.js:589:27)
    at Node.reduce (C:\cygwin64\home\Joe\dev\texts\node_modules\collections\sorted-set.js:589:27)
    at Node.reduce (C:\cygwin64\home\Joe\dev\texts\node_modules\collections\sorted-set.js:589:27)
    at Node.reduce (C:\cygwin64\home\Joe\dev\texts\node_modules\collections\sorted-set.js:589:27)
    at Node.reduce (C:\cygwin64\home\Joe\dev\texts\node_modules\collections\sorted-set.js:589:27)
    at Node.reduce (C:\cygwin64\home\Joe\dev\texts\node_modules\collections\sorted-set.js:589:27)
    at Node.reduce (C:\cygwin64\home\Joe\dev\texts\node_modules\collections\sorted-set.js:589:27)
@marchant
Copy link
Member

In which JS environment, browser or node? A use case would be appreciated

@kriskowal
Copy link
Member

Seems the recursive solution has outlived it usefulness. Any interest in
writing a depth first traversing alternative?
On Sat, Oct 15, 2016 at 12:50 AM Benoit Marchant notifications@github.com
wrote:

In which JS environment, browser or node? A use case would be appreciated


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#164 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AADrhpBZKA4kxaSPzMEsbgjaRkcaXqB5ks5q0IXhgaJpZM4KXnMr
.

@royaldark
Copy link
Author

I experienced it in Node. Here is a simple reproduction:

const SortedSet = require("collections/sorted-set");

const vals = [];

for (let i = 0; i < 10000; i++) {
    vals.push(i);
}

const set = new SortedSet(vals);

console.log(set.toArray());
/home/Joe/dev/node_modules/collections/sorted-set.js:584
Node.prototype.reduce = function (callback, basis, index, thisp, tree, depth) {
                                 ^

RangeError: Maximum call stack size exceeded
    at Node.reduce (/home/Joe/dev/node_modules/collections/sorted-set.js:584:34)
    at Node.reduce (/home/Joe/dev/node_modules/collections/sorted-set.js:589:27)
    at Node.reduce (/home/Joe/dev/node_modules/collections/sorted-set.js:589:27)
    at Node.reduce (/home/Joe/dev/node_modules/collections/sorted-set.js:589:27)
    at Node.reduce (/home/Joe/dev/node_modules/collections/sorted-set.js:589:27)
    at Node.reduce (/home/Joe/dev/node_modules/collections/sorted-set.js:589:27)
    at Node.reduce (/home/Joe/dev/node_modules/collections/sorted-set.js:589:27)
    at Node.reduce (/home/Joe/dev/node_modules/collections/sorted-set.js:589:27)
    at Node.reduce (/home/Joe/dev/node_modules/collections/sorted-set.js:589:27)
    at Node.reduce (/home/Joe/dev/node_modules/collections/sorted-set.js:589:27)

@hthetiot hthetiot added the bug label Dec 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants