Closed paulkernfeld closed 8 years ago
My pull request is here: feross/simple-peer#61
What version of node? Please run node --version
. This sounds like a bug in wrtc
.
I'm using node 5.5.0.
Maybe this is just mincing words, but I'm not sure if I would say that this is a bug in wrtc, since it doesn't claim to allow Buffers (see js-platform/node-webrtc#103).
In node 5.5, it looks like Buffers are considered to be typed arrays by is-typedarray. I'm not sure if that's true in other versions of node; I'll check it out.
paul ~/projects/swarmhub master $ node --version
v5.5.0
paul ~/projects/swarmhub master $ node
> require('is-typedarray')(Buffer([1,2]))
true
Buffer is a subclass of Uint8Array since iojs v3 and node v4. So, for any Buffer buf
, this should be true: buf instanceof Uint8Array
. That's why I think it's ultimately a bug in wrtc
.
That issue about wrtc
not supporting buffers is old, from the time before Buffer
was implemented as a subclass of Uint8Array
.
When I run the unit tests for node.js, they fail:
Bizarrely, that Buffer translates to:
I think the reason it's failing is because simple-peer isn't converting Buffers to UInt8Arrays, because isTypedArray returns true for... most Buffers? All Buffers? I'll try to make a pull request that fixes this.