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

Maximum Call stack size reached on Shim-Array #241

Open
raghuindra opened this issue Jun 17, 2020 · 14 comments
Open

Maximum Call stack size reached on Shim-Array #241

raghuindra opened this issue Jun 17, 2020 · 14 comments

Comments

@raghuindra
Copy link

Main project has dependent on collections/shim-array and one of its npm package also depends upon collections/shim-array.
And whenever in the code we imported(required) both packages, node js returning Maximum call stack size.
Same scenario is not happening with any other such inter dependency packs like mongoose, geolib, etc.

@ejames17
Copy link

ejames17 commented Aug 25, 2020

same here. I rolled back to v5.0.0

@robross0606
Copy link

robross0606 commented Mar 1, 2021

Seeing same thing here for me:

    RangeError: Maximum call stack size exceeded

      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:30:5)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)
      at Function.Object.<anonymous>.Array.from [as nativeFrom] (node_modules/collections/shim-array.js:31:22)

I could not get it to work fixed a version 5.0.0 either. Had to stop using it altogether as it interferred badly with Apollo GraphQL API. This looks to be using Monkey patching which is asking for trouble.

@marchant
Copy link
Member

marchant commented Mar 1, 2021

Committed a tentative fix on master, please try it and let me know if it fixes it.

@matthiasg
Copy link

matthiasg commented Mar 2, 2021

Just wanted to use collections for the first time. The algorithms implemented looked decent, but to be honest, I am quite disappointed that importing e.g. collections/sorted-map would shim global objects. Not only because of the above error I just fell in as well, and going back to 5.0.0 did not help (it does not seem to support generators ?).

In general I find shimming of global objects like overwriting Array.from something to be avoided. If it absolutely has to be, it should be an opt-in feature.

I do not see a need for SortedMap for example to shim anything. As shimming seems to be deeply embedded, the risk of it breaking existing code at a fundamental and global level is just too high.

@Robula
Copy link

Robula commented Mar 3, 2021

We've just hit this too on 5.1.12. Forcing the resolution to 5.0.0 has worked.

Note: We aren't using collections directly, it is a transitive dependency via another package.

EDIT: @marchant For the sake of this issue and your request, I tried your fix on master and it works. 👍

@NebzHB
Copy link

NebzHB commented Dec 27, 2021

Dears,
I have the same problem when using collections on dependancies of homebridge-alexa (in mqtt dependancies) :
RangeError: Maximum call stack size exceeded
at Function.Array.from (/usr/local/lib/node_modules/homebridge-alexa/node_modules/collections/shim-array.js:32:22)
at Function.Array.from (/usr/local/lib/node_modules/homebridge-alexa/node_modules/collections/shim-array.js:32:22)
at Function.Array.from (/usr/local/lib/node_modules/homebridge-alexa/node_modules/collections/shim-array.js:32:22)
at Function.Array.from (/usr/local/lib/node_modules/homebridge-alexa/node_modules/collections/shim-array.js:32:22)
at Function.Array.from (/usr/local/lib/node_modules/homebridge-alexa/node_modules/collections/shim-array.js:32:22)
at Function.Array.from (/usr/local/lib/node_modules/homebridge-alexa/node_modules/collections/shim-array.js:32:22)
at Function.Array.from (/usr/local/lib/node_modules/homebridge-alexa/node_modules/collections/shim-array.js:32:22)
at Function.Array.from (/usr/local/lib/node_modules/homebridge-alexa/node_modules/collections/shim-array.js:32:22)
at Function.Array.from (/usr/local/lib/node_modules/homebridge-alexa/node_modules/collections/shim-array.js:32:22)
at Function.Array.from (/usr/local/lib/node_modules/homebridge-alexa/node_modules/collections/shim-array.js:32:22)

5.1.12 is installed but doesn't contain the if(!Array.nativeForm) condition on line 32. but even if i use it, i still have the error (on line 35)...

the error is on the return Array.nativeFrom(values, mapFn, thisArg);

@NorthernMan54
Copy link

@marchant - Is it possible to get this fix pushed out as a release ?

In the homebridge community we have had numerous users of our packages impacted by this issue due to the usage of mqtt.

@NebzHB
Copy link

NebzHB commented Dec 28, 2021

this fix doesn't fix the issue :( i've tried it

@NorthernMan54
Copy link

@NebzHB - When I was testing, I applied the fix to all the plugins leveraging collections and that appeared to resolve the issue. Did you try that

@NebzHB
Copy link

NebzHB commented Dec 28, 2021

not to all of them, i'll try

@NebzHB
Copy link

NebzHB commented Dec 28, 2021

well... homebridge-camera-ffmpeg seems to still use it (^4.2.8) but doesn't crash here... so with only changing homebridge-alexa, it doesn't solve. but push to release anyway, we'll see ;)

@redboltz
Copy link

redboltz commented Dec 29, 2021

I tried to reproduce the issue using minimal code.

When I import (emulation code) version 5.1.12 once, it works fine.
https://wandbox.org/permlink/hmddUMmg9KvZGz94

However, I import version 5.1.12 twice, then infinity recursive call happens.
https://wandbox.org/permlink/bmniUnfwt8nqlrVB

If import order is 5.1.12 -> master, then it works fine.
https://wandbox.org/permlink/a6ttiL4PrB59cnN6

If import order is master -> 5.1.12, then infinity recursive call happens.
https://wandbox.org/permlink/SqR662bKByM5pou6

If import master twice, then it works fine.
https://wandbox.org/permlink/NhufBWIaU42d6aa6

NOTE: master is 85f00f8

So in order to fix the issue, all of collections library need to update.
(The first import is exception but depending on the order is dangerous)

After the current master including 85f00f8 fix would be released, and then all collections.js users would update the library, I guess that the issue would be fixed.

@marchant
Copy link
Member

I just published the latest master as version 5.1.13.

redboltz added a commit to redboltz/number-allocator that referenced this issue Dec 29, 2021
redboltz added a commit to redboltz/MQTT.js that referenced this issue Dec 29, 2021
@NorthernMan54
Copy link

@marchant Tks very much I just updated my test environment and can no longer recreate the issue. ( I validated that npm had installed collections 5.1.13 )

@redboltz tks for the pull request against mqtt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants