node-opcua-pki 6.7.1 → 6.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/pki.mjs +28 -12
- package/dist/bin/pki.mjs.map +1 -1
- package/dist/index.js +27 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1073,7 +1073,7 @@ var CertificateAuthority = class {
|
|
|
1073
1073
|
import { EventEmitter } from "events";
|
|
1074
1074
|
import fs9 from "fs";
|
|
1075
1075
|
import path6 from "path";
|
|
1076
|
-
import { withLock } from "@ster5/global-mutex";
|
|
1076
|
+
import { drainPendingLocks, withLock } from "@ster5/global-mutex";
|
|
1077
1077
|
import chalk6 from "chalk";
|
|
1078
1078
|
import chokidar from "chokidar";
|
|
1079
1079
|
import {
|
|
@@ -1735,6 +1735,7 @@ var CertificateManager = class _CertificateManager extends EventEmitter {
|
|
|
1735
1735
|
}
|
|
1736
1736
|
try {
|
|
1737
1737
|
this.state = 3 /* Disposing */;
|
|
1738
|
+
await drainPendingLocks();
|
|
1738
1739
|
for (const unreff of this.#pendingUnrefs) {
|
|
1739
1740
|
unreff();
|
|
1740
1741
|
}
|
|
@@ -2273,22 +2274,31 @@ var CertificateManager = class _CertificateManager extends EventEmitter {
|
|
|
2273
2274
|
...usePolling ? { interval: pollingInterval } : {},
|
|
2274
2275
|
persistent: false
|
|
2275
2276
|
};
|
|
2276
|
-
const
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2277
|
+
const allCapturedHandles = [];
|
|
2278
|
+
const origWatch = fs9.watch;
|
|
2279
|
+
let watcherReadyCount = 0;
|
|
2280
|
+
const totalWatchers = 5;
|
|
2281
|
+
fs9.watch = ((...args) => {
|
|
2282
|
+
const handle = origWatch.apply(fs9, args);
|
|
2283
|
+
handle.setMaxListeners(handle.getMaxListeners() + 1);
|
|
2284
|
+
handle.on("error", () => {
|
|
2283
2285
|
});
|
|
2286
|
+
allCapturedHandles.push(handle);
|
|
2287
|
+
return handle;
|
|
2288
|
+
});
|
|
2289
|
+
const createUnreffedWatcher = (folder) => {
|
|
2290
|
+
const startIdx = allCapturedHandles.length;
|
|
2284
2291
|
const w = chokidar.watch(folder, chokidarOptions);
|
|
2285
2292
|
const unreffAll = () => {
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2293
|
+
for (let i = startIdx; i < allCapturedHandles.length; i++) {
|
|
2294
|
+
allCapturedHandles[i].unref();
|
|
2295
|
+
}
|
|
2296
|
+
watcherReadyCount++;
|
|
2297
|
+
if (watcherReadyCount >= totalWatchers) {
|
|
2298
|
+
fs9.watch = origWatch;
|
|
2289
2299
|
}
|
|
2290
2300
|
};
|
|
2291
|
-
return { w, capturedHandles, unreffAll };
|
|
2301
|
+
return { w, capturedHandles: allCapturedHandles.slice(startIdx), unreffAll };
|
|
2292
2302
|
};
|
|
2293
2303
|
await Promise.all([
|
|
2294
2304
|
this.#scanCertFolder(this.trustedFolder, this.#thumbs.trusted),
|
|
@@ -2350,6 +2360,9 @@ var CertificateManager = class _CertificateManager extends EventEmitter {
|
|
|
2350
2360
|
*/
|
|
2351
2361
|
#startCrlWatcher(folder, index, createUnreffedWatcher, store) {
|
|
2352
2362
|
const { w, unreffAll } = createUnreffedWatcher(folder);
|
|
2363
|
+
w.on("error", (err) => {
|
|
2364
|
+
debugLog(`chokidar CRL watcher error on ${folder}:`, err);
|
|
2365
|
+
});
|
|
2353
2366
|
let ready = false;
|
|
2354
2367
|
w.on("unlink", (filename) => {
|
|
2355
2368
|
for (const [key, data] of index.entries()) {
|
|
@@ -2385,6 +2398,9 @@ var CertificateManager = class _CertificateManager extends EventEmitter {
|
|
|
2385
2398
|
*/
|
|
2386
2399
|
#startWatcher(folder, index, createUnreffedWatcher, store) {
|
|
2387
2400
|
const { w, unreffAll } = createUnreffedWatcher(folder);
|
|
2401
|
+
w.on("error", (err) => {
|
|
2402
|
+
debugLog(`chokidar cert watcher error on ${folder}:`, err);
|
|
2403
|
+
});
|
|
2388
2404
|
let ready = false;
|
|
2389
2405
|
w.on("unlink", (filename) => {
|
|
2390
2406
|
debugLog(chalk6.cyan(`unlink in folder ${folder}`), filename);
|