-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[Bug]: Errors do not result in an error event #1939
Comments
This error comes from mqtt-packet stream: https://github.com/mqttjs/mqtt-packet/blob/1f2cf7f98ae036fae97096299d6237ae442ff9d8/writeToStream.js#L204 Also here we are listening to mqtt-packet errors, the problem is that emitting ALL errors causes problems in browsers as explained in the comment inside What you could do is to subscribe to stream errors manually: // initialize client
client.stream.on('errror', (err) => {
// do what you want
}) |
Hi, thanks for the reply.
Yes but that's an internal dependency that I have no interaction with -
Yes I saw Even if there is some strange browser issue then it should be checking whether it's in a browser, not fudging it with
|
@SystemParadox I agree with your statements above, would you like to send a PR to fix the above issue? Last time I checked that seems that emitting errors caused unwanted disconnections so I just preferred to keep the things like this to prevent regressions. Consider that I already improved errors emitted in #1752 #1781 #1798. What I don't understand is why this isn't picked up by Line 862 in 3e252e7
stream.destroy(err) so err should be emitted based on nodejs docs
|
As far as I can work out
Seems like you've had lots of reports due to hiding errors! I saw various mentioning of the browser issue but nothing that gave me any more info as to what the problem actually is. I really feel like we should just bin this check and consistently always emit errors. But I'm not using this in a browser at all so I can't do any testing here which isn't ideal. Side question - how do you get the test runner to only run some tests? |
I've added a test but it's failing for websockets with |
Just to be clear, I'm not the creator of MQTTjs, I'm a developer like you that uses this package, I maintain this repo since ~2 years now, it was almost unmaintained when I asked the permissions to continue the development :) This is an issue that exists from far before I started working on this
I think it is, yeah, and I'm not sure that's the only one.
I suggest you to give a look at: https://github.com/mqttjs/MQTT.js/blob/main/DEVELOPMENT.md , use |
MQTTjs Version
5.8.0
Broker
other
Environment
NodeJS
Description
For many kinds of error all you get is a
close
event - theerror
event is not emitted so you have no idea what the problem is.Adding
DEBUG=mqttjs:*
shows the following:I should not have to enable
DEBUG
to see this, theerror
event should have been emitted to inform the rest of my application.I checked the source and for some reason
this.stream.on('error')
seems tonoop
anything without anerr.code
which seems very wrong to me.Minimal Reproduction
One simple way to reproduce is to try connecting with a password but no username, but it seems to suppress almost everything.
Debug logs
The text was updated successfully, but these errors were encountered: