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/index.js CHANGED
@@ -1764,6 +1764,7 @@ var CertificateManager = class _CertificateManager extends import_node_events.Ev
1764
1764
  }
1765
1765
  try {
1766
1766
  this.state = 3 /* Disposing */;
1767
+ await (0, import_global_mutex.drainPendingLocks)();
1767
1768
  for (const unreff of this.#pendingUnrefs) {
1768
1769
  unreff();
1769
1770
  }
@@ -2302,22 +2303,31 @@ var CertificateManager = class _CertificateManager extends import_node_events.Ev
2302
2303
  ...usePolling ? { interval: pollingInterval } : {},
2303
2304
  persistent: false
2304
2305
  };
2305
- const createUnreffedWatcher = (folder) => {
2306
- const capturedHandles = [];
2307
- const origWatch = import_node_fs9.default.watch;
2308
- import_node_fs9.default.watch = ((...args) => {
2309
- const handle = origWatch.apply(import_node_fs9.default, args);
2310
- capturedHandles.push(handle);
2311
- return handle;
2306
+ const allCapturedHandles = [];
2307
+ const origWatch = import_node_fs9.default.watch;
2308
+ let watcherReadyCount = 0;
2309
+ const totalWatchers = 5;
2310
+ import_node_fs9.default.watch = ((...args) => {
2311
+ const handle = origWatch.apply(import_node_fs9.default, args);
2312
+ handle.setMaxListeners(handle.getMaxListeners() + 1);
2313
+ handle.on("error", () => {
2312
2314
  });
2315
+ allCapturedHandles.push(handle);
2316
+ return handle;
2317
+ });
2318
+ const createUnreffedWatcher = (folder) => {
2319
+ const startIdx = allCapturedHandles.length;
2313
2320
  const w = import_chokidar.default.watch(folder, chokidarOptions);
2314
2321
  const unreffAll = () => {
2315
- import_node_fs9.default.watch = origWatch;
2316
- for (const h of capturedHandles) {
2317
- h.unref();
2322
+ for (let i = startIdx; i < allCapturedHandles.length; i++) {
2323
+ allCapturedHandles[i].unref();
2324
+ }
2325
+ watcherReadyCount++;
2326
+ if (watcherReadyCount >= totalWatchers) {
2327
+ import_node_fs9.default.watch = origWatch;
2318
2328
  }
2319
2329
  };
2320
- return { w, capturedHandles, unreffAll };
2330
+ return { w, capturedHandles: allCapturedHandles.slice(startIdx), unreffAll };
2321
2331
  };
2322
2332
  await Promise.all([
2323
2333
  this.#scanCertFolder(this.trustedFolder, this.#thumbs.trusted),
@@ -2379,6 +2389,9 @@ var CertificateManager = class _CertificateManager extends import_node_events.Ev
2379
2389
  */
2380
2390
  #startCrlWatcher(folder, index, createUnreffedWatcher, store) {
2381
2391
  const { w, unreffAll } = createUnreffedWatcher(folder);
2392
+ w.on("error", (err) => {
2393
+ debugLog(`chokidar CRL watcher error on ${folder}:`, err);
2394
+ });
2382
2395
  let ready = false;
2383
2396
  w.on("unlink", (filename) => {
2384
2397
  for (const [key, data] of index.entries()) {
@@ -2414,6 +2427,9 @@ var CertificateManager = class _CertificateManager extends import_node_events.Ev
2414
2427
  */
2415
2428
  #startWatcher(folder, index, createUnreffedWatcher, store) {
2416
2429
  const { w, unreffAll } = createUnreffedWatcher(folder);
2430
+ w.on("error", (err) => {
2431
+ debugLog(`chokidar cert watcher error on ${folder}:`, err);
2432
+ });
2417
2433
  let ready = false;
2418
2434
  w.on("unlink", (filename) => {
2419
2435
  debugLog(import_chalk6.default.cyan(`unlink in folder ${folder}`), filename);