-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
Description
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