Skip to content

Conversation

@jdiamond
Copy link
Contributor

@jdiamond jdiamond commented Sep 5, 2016

This fixes the tests that were failing due to various changes in mqtt-packet since the last time mqtt-connection was worked on.

That 2MB payload test that I had to increase the timeout for is taking 6-8 seconds to run on my Mac. Seems strange.

Maybe it might also be worth updating the Travis file to include Node 4 and 6? I've never used Travis so I'll leave that to you.

@jdiamond
Copy link
Contributor Author

jdiamond commented Sep 5, 2016

The .travis.yml file is trying to install a version of npm that's no longer available?

@jdiamond
Copy link
Contributor Author

jdiamond commented Sep 5, 2016

Well, now I can no longer say I've never used Travis before. =)

So it looks like the version of npm that came with 0.8 doesn't work with this package.json. That must be why you were installing that specific version of npm. Do you still want to support 0.8?

The build for 0.10 failed because a Buffer is being passed to Buffer.byteLength() but that's not allowed in 0.10.

While looking into that, I noticed the stack traces for mqtt-packet files don't correspond to the latest. mqtt-connection is still depending on mqtt-packet@^3.0.0.

Using latest mqtt-packet still fails on 0.10, but everything is working on 4 and 6. Do you still want to support 0.10?

before_install:
- npm install npm@v1.4-latest -g
- 6
- 4
Copy link
Member

Choose a reason for hiding this comment

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

great! 👍

@mcollina
Copy link
Member

mcollina commented Sep 5, 2016

So it looks like the version of npm that came with 0.8 doesn't work with this package.json. That must be why you were installing that specific version of npm. Do you still want to support 0.8?

As you guessed, no.

While looking into that, I noticed the stack traces for mqtt-packet files don't correspond to the latest. mqtt-connection is still depending on mqtt-packet@^3.0.0.

Yes. mqtt-packet v4 does not work on v0.8. Thanks for updating!

Using latest mqtt-packet still fails on 0.10, but everything is working on 4 and 6. Do you still want to support 0.10?

No, we'll bump the major

@mcollina
Copy link
Member

mcollina commented Sep 5, 2016

@jdiamond do you want to help maintaining this module?

That 2MB payload test that I had to increase the timeout for is taking 6-8 seconds to run on my Mac. Seems strange.

The problem relies on the difference between mqtt-packet v3 and v4. You should update this library to use https://github.com/mqttjs/mqtt-packet#writeToStream and not generate. Here is an example: https://github.com/mqttjs/MQTT.js/blob/v2-dev/lib/client.js#L32-L51.

@jdiamond
Copy link
Contributor Author

jdiamond commented Sep 5, 2016

I updated mqtt-connection to use writeToStream. That didn't end up helping make the 2MB tests faster. It seems like it was should.eql that was being slow comparing the 2MB buffers so I changed those two tests to just check the length.

The way writeToStream does multiple writes to its output stream means multiple readable events were being triggered, breaking many tests that assumed they would only get one. I made a helper function (readFromStream) in the tests to deal with that.

writeToStream doesn't really have an API that's usable with through2 so I had to make a custom duplex stream. reduplexer was giving me an error I didn't understand, but it worked with duplexify. I tried to replace the other use of reduplexer with duplexify and got a different error that I'll look into a bit later.

I also tried to update through2 to latest, but the tests failed. I'll look into that later, too.

I think swapping out reduplexer for duplexify (I saw your comments in the reduplexer issues about possibly switching) and updating through2 are the last things needed to modernize mqtt-connection.

opts = opts || {}

var inStream = generateStream()
var inStream = writeToStream()
Copy link
Member

Choose a reason for hiding this comment

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

Is generateStream still being used?

Copy link
Member

Choose a reason for hiding this comment

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

You don't need to create a stream. You can pass the original duplex directly to writeToStream.

Copy link
Contributor Author

@jdiamond jdiamond Sep 14, 2016

Choose a reason for hiding this comment

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

No, generateStream isn't being used inside mqtt-connection anymore. It's part of the public API so I left it as is. Do you want me to remove the whole file or just the reference to it from this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

About passing in the original duplex stream...I guess I was trying to keep the API compatible with the old generateStream, but I think I see what you mean about being able to use that instead of creating the PassThrough stream. For a while, I was toggling between generateStream and writeToStream to ensure the tests were passing with both implementations.

@mcollina
Copy link
Member

mcollina commented Sep 7, 2016

Do you want to help maintaining this and mqtt-packet? I will add you to the organization.

@jdiamond
Copy link
Contributor Author

jdiamond commented Sep 7, 2016

I don't mind helping. I think I'm already in the org from last time I helped with MQTT.js.

@jdiamond
Copy link
Contributor Author

I finished upgrading all of the dependencies and all the existing tests pass quickly now. Let me know if you think anything else needs to be done.

@mcollina mcollina merged commit ecacb78 into mqttjs:master Sep 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants