@monoes/monomindcli 2.15.2 → 2.15.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.
@@ -60,11 +60,21 @@ function mapWaitUntil(waitUntil) {
60
60
  return 'load';
61
61
  }
62
62
 
63
+ // This timer is deliberately NOT unref'd. Both call sites race it against CDP
64
+ // I/O that can die silently: goto() awaits a promise settled only by a
65
+ // Page.loadEventFired/domContentEventFired event, and close() races
66
+ // Browser.close — the very command that tears the websocket down. An unref'd
67
+ // timer never fires once nothing else pins the event loop, and a launched
68
+ // Chrome is detached and unref'd, so that websocket is the only ref'd handle
69
+ // here — exactly the one that goes away. Node would then consider the loop
70
+ // drained and exit 0 with the race still pending, instead of surfacing the
71
+ // timeout. The .finally() below clears it either way, so keeping it ref'd
72
+ // only ever costs a caller `ms`, never a hang. (Same rule as monobrowse's
73
+ // waitForProcessExit, #314.)
63
74
  function withTimeout(promise, ms, label) {
64
75
  let handle;
65
76
  const timeout = new Promise((_, reject) => {
66
77
  handle = setTimeout(() => reject(new Error(`Timeout waiting for ${label} after ${ms}ms`)), ms);
67
- handle.unref?.();
68
78
  });
69
79
  return Promise.race([promise, timeout]).finally(() => clearTimeout(handle));
70
80
  }