diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 0c6db85e..93078ccb 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -65,7 +65,8 @@ jobs: docker: node:18-alpine docker_cmd: apk add --no-cache pkgconfig curl tar python3 make gcc g++ cmake - musl-dev && npm i -g pnpm && pnpm install && pnpm run build.prebuild + musl-dev && npm i -g pnpm && pnpm install && pnpm run + build.prebuild node_version: 18 node_arch: x64 ARCH: x64 diff --git a/package.json b/package.json index 29815452..77834477 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ "scripts": { "install": "(shx test -f ./script/build.js || run-s build.js) && cross-env npm_config_build_from_source=true aminya-node-gyp-build", "clean": "shx rm -rf ./build ./lib/ ./prebuilds ./script/*.js ./script/*.js.map ./script/*.d.ts ./script/*.tsbuildinfo", - "clean.temp": "shx rm -rf ./tmp && shx mkdir -p ./tmp && shx touch ./tmp/.gitkeep", + "clean.temp": "shx rm -rf ./tmp && shx mkdir -p ./tmp", "build.library": "tsc -p ./src/tsconfig.json", "build.script": "tsc -p ./script/tsconfig.json && tsc -p ./script/tsconfig.esm.json", "build.js": "run-p build.script build.library", @@ -94,9 +94,9 @@ "build": "run-s build.js build.native", "build.debug": "run-s build.js build.native.debug", "test.deps": "cd test && pnpm install && cd ..", - "test": "run-s test.deps build && mocha --exit", - "test.skip_gc_tests": "run-s test.deps build.debug && cross-env SKIP_GC_TESTS=true mocha --exit", - "test.electron.main": "run-s test.deps build && electron-mocha", + "test": "run-s clean.temp test.deps build && mocha", + "test.skip_gc_tests": "run-s clean.temp test.deps build.debug && cross-env SKIP_GC_TESTS=true mocha", + "test.electron.main": "run-s clean.temp test.deps build && electron-mocha", "format": "prettier --write .", "test.electron.renderer": "run-s build && electron-mocha --renderer", "lint.clang-format": "clang-format -i -style=file ./src/*.cc ./src/*.h ./src/util/*.h", diff --git a/script/tsconfig.esm.json b/script/tsconfig.esm.json index 698433fd..9789fa80 100644 --- a/script/tsconfig.esm.json +++ b/script/tsconfig.esm.json @@ -2,7 +2,7 @@ "extends": "./tsconfig.json", "compilerOptions": { "module": "ESNext", - "moduleResolution": "node", + "moduleResolution": "node" }, "include": ["./**/*.mts"], "exclude": [] diff --git a/src/util/error.h b/src/util/error.h index 1526aad3..abde56c1 100644 --- a/src/util/error.h +++ b/src/util/error.h @@ -48,7 +48,7 @@ static inline Napi::Error ErrnoException( static inline Napi::Error ErrnoException( const Napi::Env& env, int32_t error, const std::string& address) { - auto exception = ErrnoException(env, error); + auto exception = ErrnoException(env, error, nullptr); exception.Set("address", Napi::String::New(env, address)); return exception; } diff --git a/test/unit/helpers.ts b/test/unit/helpers.ts index a9a823aa..5c49282f 100644 --- a/test/unit/helpers.ts +++ b/test/unit/helpers.ts @@ -1,5 +1,6 @@ import * as path from "path" import * as semver from "semver" +import * as fs from "fs" import {spawn} from "child_process" @@ -21,6 +22,9 @@ export function uniqAddress(proto: Proto) { switch (proto) { case "ipc": { const sock = path.resolve(__dirname, `../../tmp/${proto}-${id}`) + // create the directory + fs.mkdirSync(path.dirname(sock), {recursive: true}) + return `${proto}://${sock}` } @@ -28,6 +32,7 @@ export function uniqAddress(proto: Proto) { case "udp": return `${proto}://127.0.0.1:${id}` + case "inproc": default: return `${proto}://${proto}-${id}` } diff --git a/test/unit/proxy-router-dealer-test.ts b/test/unit/proxy-router-dealer-test.ts index 2bd5ecc2..889cee58 100644 --- a/test/unit/proxy-router-dealer-test.ts +++ b/test/unit/proxy-router-dealer-test.ts @@ -6,6 +6,11 @@ import {testProtos, uniqAddress} from "./helpers" for (const proto of testProtos("tcp", "ipc", "inproc")) { describe(`proxy with ${proto} router/dealer`, function () { + /* ZMQ < 4.0.5 has no steerable proxy support. */ + if (semver.satisfies(zmq.version, "< 4.0.5")) { + return + } + let proxy: zmq.Proxy let frontAddress: string @@ -15,11 +20,6 @@ for (const proto of testProtos("tcp", "ipc", "inproc")) { let rep: zmq.Reply beforeEach(async function () { - /* ZMQ < 4.0.5 has no steerable proxy support. */ - if (semver.satisfies(zmq.version, "< 4.0.5")) { - this.skip() - } - proxy = new zmq.Proxy(new zmq.Router(), new zmq.Dealer()) frontAddress = uniqAddress(proto) @@ -89,6 +89,8 @@ for (const proto of testProtos("tcp", "ipc", "inproc")) { rep.close() } + console.log("waiting for messages") + await Promise.all([echo(), send()]) assert.deepEqual(received, messages) diff --git a/test/unit/proxy-terminate-test.ts b/test/unit/proxy-terminate-test.ts index b36c0a4c..80b89d9b 100644 --- a/test/unit/proxy-terminate-test.ts +++ b/test/unit/proxy-terminate-test.ts @@ -7,14 +7,14 @@ import {isFullError} from "../../src/errors" for (const proto of testProtos("tcp", "ipc", "inproc")) { describe(`proxy with ${proto} terminate`, function () { + /* ZMQ < 4.0.5 has no steerable proxy support. */ + if (semver.satisfies(zmq.version, "< 4.0.5")) { + return + } + let proxy: zmq.Proxy beforeEach(async function () { - /* ZMQ < 4.0.5 has no steerable proxy support. */ - if (semver.satisfies(zmq.version, "< 4.0.5")) { - this.skip() - } - proxy = new zmq.Proxy(new zmq.Router(), new zmq.Dealer()) }) @@ -28,12 +28,13 @@ for (const proto of testProtos("tcp", "ipc", "inproc")) { await proxy.frontEnd.bind(uniqAddress(proto)) await proxy.backEnd.bind(uniqAddress(proto)) - try { - const timer = setTimeout(() => proxy.terminate(), 50) - await proxy.run() + const sleep_ms = 50 + + setTimeout(() => proxy.terminate(), sleep_ms) + await proxy.run() + try { await proxy.terminate() - timer.unref() assert.ok(false) } catch (err) { if (!isFullError(err)) { diff --git a/test/unit/typings-compatibility-test.ts b/test/unit/typings-compatibility-test.ts index b0677953..4b9675f2 100644 --- a/test/unit/typings-compatibility-test.ts +++ b/test/unit/typings-compatibility-test.ts @@ -8,7 +8,7 @@ import { readFile, writeFile, } from "fs-extra" -import * as which from "which" +import which from "which" import {assert} from "chai" diff --git a/tsconfig.json b/tsconfig.json index 1e58e4da..02c2001c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,6 +16,7 @@ "noUnusedParameters": false, "incremental": true, "sourceMap": true, + "esModuleInterop": true, "lib": ["ES2020", "dom"] } }