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

Exceptions like client.close/subscription.close cannot be catched

Open
#429 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Start by reproducing the double client.close() call from error-report.js with pulsar-client 1.14.0 on Node.js 20.18.1, then inspect the client.close and subscription.close entry points and how their failures reach the promise. Done means the close failure is catchable or repeated close calls are safely idempotent, with behavior verified for the reported example.

Written by the indexing model from the issue text.

Description

Not sure what would be better here, that either the exception should be catchable or it should be idempotent.

const Pulsar = require("pulsar-client");
const STAGING = {
  serviceUrl: "pulsar+ssl://any-server:6651",
};

async function main() {
  const client = new Pulsar.Client({
    ...STAGING,
    logLevel: Pulsar.LogLevel.ERROR,
    log: (level, file, line, message) => {
      console.log(`[${level}] ${file}:${line}: ${message}`);
    },
  });

  try {
    await client.close();
    await client.close();
  } catch (error) {
    console.error("omg closing client:", error);
  }
}
main();

{
  "dependencies": {
    "pulsar-client": "^1.14.0"
  }
}

Will throw

node error-report.js
node:internal/process/promises:391
    triggerUncaughtException(err, true /* fromPromise */);
    ^

[Error: Failed to close client: AlreadyClosed]

Node.js v20.18.1

Even though I catched it

Dominant language
C++
Stars
164
Forks
99
Avg merge
5d 18h
Merged PRs (30d)
2

Contributor guide

No contributing guide indexed for this repository

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 apache/pulsar-client-node

All issues in apache/pulsar-client-node

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.