montagejs / collections

This package contains JavaScript implementations of common data structures with idiomatic interfaces.
http://www.collectionsjs.com
Other
2.09k stars 185 forks source link

collections break crypto #196

Open codebling opened 6 years ago

codebling commented 6 years ago

Opening this since most of related issues #36 #70 #94 #95 #116 #139 #145 #162 #165 #169 #178 #182 #185 #197 #215 #220 have been closed and there needs to be some visibility on this.

The shims are still causing issues in collections.

I see that PRs #95 #173 and #189 #212 are still open, the merge of one or both of those should theoretically resolve this issue. (Closed PRs #94 #116 are also about the same issue)

Try this simple test case.

$ node
> require('crypto').getHashes().length
46
>
(To exit, press ^C again or type .exit)
>
$ node
> var Map = require('collections/map')
undefined
> require('crypto').getHashes().length
0
>
hthetiot commented 6 years ago

@codebling Thanks will look into #173 and #189 ASAP.

hthetiot commented 6 years ago

Works for me @codebling have you installed collections@5.1.2 ?

package.json source:

{
  "name": "collections-test",
  "main": "array.js",
  "dependencies": {
    "collections": "^5.1.2"
  }
}

array.js source:

var Map = require('collections/map');
console.log(require('crypto').getHashes().length);

Results:

node array.js 
46

Some other tests

nvm use v4
Now using node v4.8.6 (npm v2.15.11)
node 
> var Map = require('collections/map')
undefined
> require('crypto').getHashes().length
46
nvm use v8
Now using node v8.9.0 (npm v5.5.1)
node 
> var Map = require('collections/map')
undefined
> require('crypto').getHashes().length
0

Bug is on node v8 not v4.

codebling commented 6 years ago

Thanks for looking at this. Did not realise it was not broken on some node versions.

rachel-chocron commented 5 years ago

Any progress with this? I am experiencing this issue when using http://www.collectionsjs.com/sorted-set with winston file transport. It prevents me from creating a file transport.

codebling commented 5 years ago

@rachel-chocron Based on comments in all of the issues listed at the top, the root cause of all of the issues is the direct modification of the global array type by Collections. If I recall correctly, this was fixed in the v2 branch, which at the moment is not merged or supported by the montage team.

In this specific issue, hthetiot showed that it does actually work in some legacy versions of node, but later ones all seem to be broken.

Depending on which features of Collections you use, there may be acceptable substitutes available.