coinbase / coinbase-pro-node

DEPRECATED — The official Node.js library for Coinbase Pro
Apache License 2.0
840 stars 316 forks source link

WebsocketClient error #64

Closed xpepermint closed 7 years ago

xpepermint commented 7 years ago

Executing the code below (example from the readme)

const Gdax = require("gdax");
var websocket = new Gdax.WebsocketClient(['BTC-USD']);
websocket.on('message', function(data) { console.log(data); });

fails with

/myproject/node_modules/gdax/node_modules/ws/lib/Sender.js:206
      bufferUtil.mask(data, mask, outputBuffer, dataOffset, dataLength);
                ^

TypeError: Cannot read property 'mask' of undefined
    at Sender.frameAndSend (/myproject/node_modules/gdax/node_modules/ws/lib/Sender.js:206:17)
    at /myproject/node_modules/gdax/node_modules/ws/lib/Sender.js:126:12
    at /myproject/node_modules/gdax/node_modules/ws/lib/PerMessageDeflate.js:313:5
    at afterWrite (_stream_writable.js:430:3)
    at onwrite (_stream_writable.js:421:7)
    at afterTransform (_stream_transform.js:102:3)
    at TransformState.afterTransform (_stream_transform.js:75:12)
    at Zlib.callback (zlib.js:485:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! collector@1.0.0 start: `node ./src/scripts/start.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the collector@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
x

Using node v8.1.1.

nikulis commented 7 years ago

What version/commit of gdax-node are you using? I'm unable to recreate this error.

Since you're on Node 8, are you using npm 5? Because the error is being thrown from a different lib, maybe try deleting the generated package-lock.json and doing a fresh npm install.

xpepermint commented 7 years ago

The one that's published on NPM and yes, I'm using npm5.

nikulis commented 7 years ago

Hmm, is it normal to have a doubly-nested node_modules folder?

myproject/node_modules/gdax/node_modules/ws/lib/Sender.js

When I npm install gdax in a new directory, the node_modules directory is flat, e.g. gdax and ws are siblings.

fb55 commented 7 years ago

We had to scale up our websocket stack yesterday due to huge demand, this probably caused some issues in the meantime. I'm closing this for now, please let me know if this is still an issue.

gcperrin commented 7 years ago

@fb55 Getting the same error on Node LTS (6.10.0), all other API functions working.

gcperrin commented 7 years ago

@fb55 Upgrading to npm ws (1.1.1 -> 3.0.0) fixed for me, any particular reason the master is using this extremely outdated version? If not I'll submit a pull request.

fb55 commented 7 years ago

There isn't a reason, only that nobody looked into it so far. A PR would definitely be welcome.

We should set up Greenkeeper at some point to make sure we're up to date.