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

[Bug]: Errors do not result in an error event #1939

Open
SystemParadox opened this issue Sep 20, 2024 · 0 comments
Open

[Bug]: Errors do not result in an error event #1939

SystemParadox opened this issue Sep 20, 2024 · 0 comments
Labels

Comments

@SystemParadox
Copy link

MQTTjs Version

5.8.0

Broker

other

Environment

NodeJS

Description

For many kinds of error all you get is a close event - the error event is not emitted so you have no idea what the problem is.

Adding DEBUG=mqttjs:* shows the following:

mqttjs:client _writePacket :: emitting `packetsend`
mqttjs:client _writePacket :: writing to stream
mqttjs:client _writePacket :: writeToStream result false
mqttjs:client streamErrorHandler :: error Username is required to use password
mqttjs:client noop :: Error: Username is required to use password

I should not have to enable DEBUG to see this, the error 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 to noop anything without an err.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

mqttjs:client _writePacket :: emitting `packetsend`
mqttjs:client _writePacket :: writing to stream
mqttjs:client _writePacket :: writeToStream result false
mqttjs:client streamErrorHandler :: error Username is required to use password
mqttjs:client noop :: Error: Username is required to use password
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant