apache / apache/pulsar-client-node

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

Open
#429 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
164
Forks
98
PR merge metrics
No merged PRs in 30d

Description

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

```javascript
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();

```

```json
{
"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

Contributor guide

No contributing guide indexed for this repository

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.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.