node-opcua-pki 6.7.1 → 6.7.2

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