Skip to content

Commit 4831244

Browse files
Fixes for older ZMQ versions.
1 parent ea63c4a commit 4831244

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

src/observer.cc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,11 +276,10 @@ void Observer::Receive(const Napi::Promise::Deferred& res) {
276276
case ZMQ_EVENT_ACCEPT_FAILED:
277277
case ZMQ_EVENT_CLOSE_FAILED:
278278
#ifdef ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL
279-
case ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL: {
279+
case ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL:
280+
#endif
280281
event["error"] = ErrnoException(Env(), value).Value();
281282
break;
282-
}
283-
#endif
284283

285284
#ifdef ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL
286285
case ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL: {
@@ -291,10 +290,9 @@ void Observer::Receive(const Napi::Promise::Deferred& res) {
291290
#endif
292291

293292
#ifdef ZMQ_EVENT_HANDSHAKE_FAILED_AUTH
294-
case ZMQ_EVENT_HANDSHAKE_FAILED_AUTH: {
293+
case ZMQ_EVENT_HANDSHAKE_FAILED_AUTH:
295294
event["error"] = StatusException(Env(), AuthError(value), value).Value();
296295
break;
297-
}
298296
#endif
299297

300298
case ZMQ_EVENT_MONITOR_STOPPED: {

test/unit/helpers.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ import {Worker} from "worker_threads"
66

77
import * as zmq from "../../src"
88

9-
/* Stop pending messages in test suite from preventing process exit. */
10-
zmq.context.blocky = false
9+
console.log(`ZeroMQ version ${zmq.version}`)
10+
if (semver.satisfies(zmq.version, ">= 4.2")) {
11+
/* Stop pending messages in test suite from preventing process exit. */
12+
zmq.context.blocky = false
13+
}
1114

1215
/* Windows cannot bind on a ports just above 1014; start higher to be safe. */
1316
let seq = 5000

test/unit/socket-xpub-xsub-test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as semver from "semver"
12
import * as zmq from "../../src"
23

34
import {assert} from "chai"
@@ -223,6 +224,9 @@ for (const proto of testProtos("tcp", "ipc", "inproc")) {
223224
})
224225

225226
it("should forward all subscriptions/unsubscriptions", async function() {
227+
/* ZMQ 4.2 first introduced ZMQ_XPUB_VERBOSER. */
228+
if (semver.satisfies(zmq.version, "< 4.2")) this.skip()
229+
226230
const address = uniqAddress(proto)
227231

228232
const subs: Buffer[] = []

0 commit comments

Comments
 (0)