Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

MQTT "Session disconnected while trying to send message to" error drops the topic

Open Beginner friendly
#3,299 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
javascript, node.js

Research direction

The error is raised in server/mqtt.ts around line 551. Read the delivery listener and check how it handles disconnected sessions and logs this error; the issue also raises whether the expected disconnect race should be logged at error level. Done when the message includes the topic and session/client id, and the logging level decision is addressed.

Written by the indexing model from the issue text.

Description

The MQTT delivery listener builds its error as:

if (disconnected) throw new Error('Session disconnected while trying to send message to', topic);

(server/mqtt.ts:551). Error's second argument is an options object, not a message part, so the topic is dropped and every log line reads "Session disconnected while trying to send message to" with nothing after it. On a busy MQTT deployment this line is logged hundreds of thousands of times a week with no way to tell which topic or session it came from.

Fix: put the topic (and the session/client id) in the message. Also worth checking whether this case should log at error level at all: a delivery racing a disconnect is expected under normal client churn.

Present in v5.2.x, v5.3.x and main.

Dominant language
JavaScript
Stars
90
Forks
15
Avg merge
1d 23h
Merged PRs (30d)
287

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from HarperFast/harper

All issues in HarperFast/harper

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.