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

Bumped ws to v2.0.0. #106

Merged
merged 4 commits into from
Apr 7, 2017
Merged

Bumped ws to v2.0.0. #106

merged 4 commits into from
Apr 7, 2017

Conversation

mcollina
Copy link
Collaborator

@mcollina mcollina commented Feb 8, 2017

Fixes #105.

This is a semver-major change, as it will work only on Node v4+.

@antoniobusrod
Copy link

Don't you prefer to stay at next https://github.com/websockets/ws/releases/tag/1.1.2 ?

@mcollina
Copy link
Collaborator Author

At some point we will have to migrate to v2.

@sublimator
Copy link

https://github.com/websockets/ws/releases/tag/2.0.0

Dropped support for Node.js < 4.5.0.

Man, AWS lambda is stuck on 4.3.2, they need to get their act together.

@simonmcl
Copy link

Linked here from @mcollina

My 2 cents:

I understand the issue and the effort involved. While my understanding of this module is limited as I'm using one which depends on this, there is a very long stack trace appearing in the console coming from v8 directly, when using Node v6+, to say that the version of bufferutils being used, is using deprecated methods (bufferutils is being used by ws).

We faced a lot of errors and crashes in Node v7 when trying to use the module, and ultimately couldn't get it to work. I realise the drop in support is not ideal, but it may become necessary very soon.

@mcollina
Copy link
Collaborator Author

@simonmcl we are not using bufferutils anywhere in this module. websocket-stream works without problem on v7 on my machine.
What errors are you seeing on Node v7? Can you open specific issues on those, or maybe contribute some unit tests so that we can improve things?

@simonmcl
Copy link

@mcollina bufferutils is a dependency of ws, which is a dependency of your module. We didn't have time to debug the v7 issue on our current project, so we just stayed with v6.9.5, we will look to upgrade another time when we have the bandwidth, just guessing it might have been related due to the deprecation warnings.

But when trying to use https://www.npmjs.com/package/ibmiotf , on node 6.9.5 a large stacktrace appears warning of deprecations for bufferutil. They are using mqtt, which is using websocket-stream.

I planned to ask them to update their dependencies, but discovered that there was no version of websocket-stream which had the appropriate version of ws to have the appropriate version of bufferutils

... anyone else's head hurting or just me?

@mcollina
Copy link
Collaborator Author

mcollina commented Mar 14, 2017

@simonmcl bufferutil is not a dependency of ws v1: https://github.com/websockets/ws/blob/v1.x/package.json#L24.

So, something else should be going on in here. I think you should open an issue on ibmiotf, and we can work with them to solve the issue. They probably have more bandwidth than us anyway.
Feel free to tag me in that issue.

@simonmcl
Copy link

@mcollina ah its a devDependency, I just searched for bufferutil, missed what brace it was in. Ok cool, i'll check this issue again and follow up with them then. Thanks for the help

@simonmcl
Copy link

@mcollina had another few minutes to look at this. Turns out the versions being used by that IOT module, is using a version of ws where bufferutil is listed as an optional dependency. It was moved to a dev dependency later on. Running npm install --no-optional solves the issue for now.

Logged an issue with the IOT module to update their versions.

Thanks for the help debugging this!

@sublimator
Copy link

sublimator commented Mar 16, 2017 via email

@simonmcl
Copy link

@sublimator no IBM's IOT platform on Bluemix

@sublimator
Copy link

sublimator commented Mar 16, 2017 via email

@sublimator
Copy link

sublimator commented Mar 16, 2017 via email

@simonmcl
Copy link

@sublimator 4.3.2? jesus thats horrific, my thoughts and prayers are with you at this difficult time lol

@sublimator
Copy link

sublimator commented Mar 16, 2017 via email

@lpinca
Copy link
Contributor

lpinca commented Apr 2, 2017

FWIW aws now (Mar 22nd, 2017) supports and recommends Node.js v6.10

@sublimator
Copy link

sublimator commented Apr 2, 2017 via email

@mcollina
Copy link
Collaborator Author

mcollina commented Apr 2, 2017

Still, a lot of people uses older version of v4. Can we get ws to work on v4.0.0? Lamda's node 4.3.2 is still there for a lot of people.

@lpinca
Copy link
Contributor

lpinca commented Apr 2, 2017

Node.js v4.5 is only required due to the use of safe Buffer APIs only available is 4.5+ but we can use https://www.npmjs.com/package/safe-buffer in ws to support all v4 versions.

stream.js Outdated
@@ -17,7 +17,7 @@ function WebSocketStream(target, protocols, options) {
if (protocols && !Array.isArray(protocols) && 'object' === typeof protocols) {
// accept the "options" Object as the 2nd argument
options = protocols
protocols = null
protocols = []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer needed. It was a regression bug which has been fixed in ws@2.2.3, sorry about that.

@@ -67,6 +67,13 @@ function WebSocketStream(target, protocols, options) {
var coerceToBuffer = options.binary || options.binary === undefined

function socketWriteNode(chunk, enc, next) {
// avoid errors, this never happens unless
// destroy() is called
if (socket.readyState !== WS.OPEN) {
Copy link
Contributor

@lpinca lpinca Apr 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I thought this has nothing to do ws@2, it is also needed for ws@1. The same issue also happens on master if you disable the permessage-deflate extension.

diff --git a/test.js b/test.js
index 18caa28..a0b10af 100644
--- a/test.js
+++ b/test.js
@@ -99,7 +99,9 @@ test('drain', function(t) {
   t.plan(1)
 
   echo.start(function() {
-    var client = websocket(echo.url, echo.options)
+    var client = websocket(echo.url, {
+      perMessageDeflate: false
+    })
 
     client.on('drain', function() {
       client.destroy()

In ws@2 this also happens with permessage-deflate enabled because data is not compressed unless the size is bigger than a configurable threshold (1024 bytes by default).

The problem with the "drain" test is that a single data chunk arrives on the server with many binary frames and a close frame. All frames are parsed on the same tick and when the close frame is processed, the readyState is set to CLOSING. The payloads of the processed binary frames are pushed to the proxy, but when socketWriteNode() is called the readyState is already CLOSING.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation.

readme.md Outdated
extension](https://tools.ietf.org/html/rfc7692) to achieve the best
throughput.

Default: `false`
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lpinca is this documented correctly?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default value is true in ws.

readme.md Outdated
extension](https://tools.ietf.org/html/rfc7692) to achieve the best
throughput.

Default: `false`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default value is true in ws.

fs.createReadStream('bigdata.json').pipe(stream)
}
```

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might makes sense to show how to disable it on the client (it's the same) as websocket-stream could be used only as a client.

@mcollina
Copy link
Collaborator Author

mcollina commented Apr 5, 2017

@lpinca is the perMessageDeflate option understood also in the browser, or is it node-specific?

@mcollina
Copy link
Collaborator Author

mcollina commented Apr 5, 2017

@lpinca forget about that question, we are not passing the options through.

@lpinca
Copy link
Contributor

lpinca commented Apr 5, 2017

The are no options in the browser interface. It depends on the browser. It is automatically negotiated when supported (if the server supports it ofc).

@mcollina mcollina mentioned this pull request Apr 5, 2017
@mcollina mcollina merged commit dc39271 into master Apr 7, 2017
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

Successfully merging this pull request may close these issues.

5 participants