Skip to content

Commit

Permalink
fix: Compatible with Node 12.3.0 and higher versions. (#378)
Browse files Browse the repository at this point in the history
(cherry picked from commit 2d659d2)
  • Loading branch information
shibd committed Apr 13, 2024
1 parent 262918a commit 4c39024
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@

The Pulsar Node.js client can be used to create Pulsar producers and consumers in Node.js. For the supported Pulsar features, see [Client Feature Matrix](https://pulsar.apache.org/client-feature-matrix/).

This library works only in Node.js 10.x or later because it uses the
[node-addon-api](https://github.com/nodejs/node-addon-api) module to wrap the C++ library.
This library works only in Node.js 12.3 or later because it uses:
1. The [node-addon-api](https://github.com/nodejs/node-addon-api) module to wrap the C++ library.
2. The [Mozilla CA](https://nodejs.org/api/tls.html#tlsrootcertificates) file, which is provided by Node.js v12.3.0 and subsequent versions.

## Getting Started

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"license": "Apache-2.0",
"gypfile": true,
"engines": {
"node": ">=10.16.0"
"node": ">=12.3.0"
},
"devDependencies": {
"@seadub/clang-format-lint": "0.0.2",
Expand Down
9 changes: 8 additions & 1 deletion src/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,14 @@ class Client {
}

static genCertFile() {
fs.rmSync(certsFilePath, { force: true });
try {
if (fs.existsSync(certsFilePath)) {
fs.unlinkSync(certsFilePath);
}
} catch (err) {
console.error(err);
}

const fd = fs.openSync(certsFilePath, 'a');
try {
tls.rootCertificates.forEach((cert) => {
Expand Down

0 comments on commit 4c39024

Please sign in to comment.