Skip to content

Commit 1e0b402

Browse files
authored
feat: Node js 24 and v8 compatibility fixes (#357)
* fix(NaN): SetAccessors should use NAN_GETTER * fix(addOn): sprintf is deprecated * fix: update dependencies * feat: add support for Node.js 24 * add changelog
1 parent 6ede077 commit 1e0b402

3 files changed

Lines changed: 18 additions & 14 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
#### v 7.1.0 (2025-11-15)
2+
* feat: Node js 24 and v8 compatibility fixes
3+
4+
Pull request [357](https://github.com/yfinkelstein/node-zookeeper/pull/357) by @davidvujic
5+
16
#### v 7.0.0 (2025-05-25)
27
* fix: enable workers
38

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "zookeeper",
33
"description": "apache zookeeper client (zookeeper async API v3.5.x - v3.8.x)",
4-
"version": "7.0.0",
4+
"version": "7.1.0",
55
"author": "Yuri Finkelstein <yurif2003@yahoo.com>",
66
"license": "MIT",
77
"contributors": [
@@ -34,17 +34,17 @@
3434
"decompress-targz": "4.1.x",
3535
"nan": "2.x",
3636
"node-gyp-build": "^4.2.3",
37-
"shelljs": "0.8.x"
37+
"shelljs": "0.10.x"
3838
},
3939
"devDependencies": {
40-
"@types/node": "17.x",
41-
"ava": "4.0.1",
40+
"@types/node": "24.x",
41+
"ava": "6.x",
4242
"eslint": "8.x",
4343
"eslint-config-airbnb-base": "15.x",
4444
"eslint-plugin-import": "2.x",
45-
"prebuildify": "5.0.0",
46-
"sinon": "12.x",
47-
"typescript": "^4.0.5"
45+
"prebuildify": "6.0.1",
46+
"sinon": "21.x",
47+
"typescript": "5.x"
4848
},
4949
"main": "./lib/index.js",
5050
"scripts": {

src/node-zk.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ namespace zk {
6666
#else
6767
#define ZERO_MEM(member) bzero(&(member), sizeof(member))
6868
#endif
69-
#define _LL_CAST_ (long long)
7069
#define _LLP_CAST_ (long long *)
7170

7271
#define THROW_IF_NOT(condition, text) if (!(condition)) { \
@@ -514,7 +513,7 @@ class ZooKeeper: public Nan::ObjectWrap {
514513
static Local<String> idAsString (int64_t id) {
515514
Nan::EscapableHandleScope scope;
516515
char idbuff [128] = {0};
517-
sprintf(idbuff, "%llx", _LL_CAST_ id);
516+
snprintf(idbuff, sizeof(idbuff), "%llx", (unsigned long long) id);
518517
return scope.Escape(LOCAL_STRING(idbuff));
519518
}
520519

@@ -1027,7 +1026,7 @@ class ZooKeeper: public Nan::ObjectWrap {
10271026
CALLBACK_EPILOG();
10281027
}
10291028

1030-
static NAN_PROPERTY_GETTER(StatePropertyGetter) {
1029+
static NAN_GETTER(StatePropertyGetter) {
10311030
assert(info.This().IsEmpty() == false);
10321031
assert(info.This()->IsObject());
10331032
ZooKeeper *zk = ObjectWrap::Unwrap<ZooKeeper>(info.This());
@@ -1036,25 +1035,25 @@ class ZooKeeper: public Nan::ObjectWrap {
10361035
RETURN_VALUE(info, Nan::New<Integer> (zk->zhandle != 0 ? zoo_state(zk->zhandle) : 0));
10371036
}
10381037

1039-
static NAN_PROPERTY_GETTER(ClientidPropertyGetter) {
1038+
static NAN_GETTER(ClientidPropertyGetter) {
10401039
ZooKeeper *zk = ObjectWrap::Unwrap<ZooKeeper>(info.This());
10411040
assert(zk);
10421041
RETURN_VALUE(info, zk->idAsString(zk->zhandle != 0 ? zoo_client_id(zk->zhandle)->client_id : zk->myid.client_id));
10431042
}
10441043

1045-
static NAN_PROPERTY_GETTER(ClientPasswordPropertyGetter) {
1044+
static NAN_GETTER(ClientPasswordPropertyGetter) {
10461045
ZooKeeper *zk = ObjectWrap::Unwrap<ZooKeeper>(info.This());
10471046
assert(zk);
10481047
RETURN_VALUE(info, zk->PasswordToHexString(zk->zhandle != 0 ? zoo_client_id(zk->zhandle)->passwd : zk->myid.passwd));
10491048
}
10501049

1051-
static NAN_PROPERTY_GETTER(SessionTimeoutPropertyGetter) {
1050+
static NAN_GETTER(SessionTimeoutPropertyGetter) {
10521051
ZooKeeper *zk = ObjectWrap::Unwrap<ZooKeeper>(info.This());
10531052
assert(zk);
10541053
RETURN_VALUE(info, Nan::New<Integer> (zk->zhandle != 0 ? zoo_recv_timeout(zk->zhandle) : -1));
10551054
}
10561055

1057-
static NAN_PROPERTY_GETTER(IsUnrecoverablePropertyGetter) {
1056+
static NAN_GETTER(IsUnrecoverablePropertyGetter) {
10581057
ZooKeeper *zk = ObjectWrap::Unwrap<ZooKeeper>(info.This());
10591058
assert(zk);
10601059
RETURN_VALUE(info, Nan::New<Integer> (zk->zhandle != 0 ? is_unrecoverable(zk->zhandle) : 0));

0 commit comments

Comments
 (0)