next-issue 6.6.48 → 6.6.49

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.
@@ -1,3 +1,4 @@
1
+ import { refuseWhenStopped } from './children.mjs';
1
2
  import { minutesToMs, secondsToMs } from './durations.mjs';
2
3
  import { asError } from './errors.mjs';
3
4
  import { pause, REAL_CLOCK } from './poll.mjs';
@@ -20,6 +21,7 @@ export async function pollChecks(probe, options, clock = REAL_CLOCK) {
20
21
  let shown;
21
22
  let failures = 0;
22
23
  for (;;) {
24
+ refuseWhenStopped();
23
25
  if (rest() === 0) {
24
26
  return 'timeout';
25
27
  }
package/dist/poll.mjs CHANGED
@@ -1,9 +1,25 @@
1
1
  import { setTimeout as delay } from 'node:timers/promises';
2
+ import { onStop, runStopped } from './children.mjs';
2
3
  import { secondsToMs, timerMs } from './durations.mjs';
3
4
  export const REAL_CLOCK = {
4
5
  now: () => Date.now(),
5
- sleep: (ms) => delay(ms),
6
+ sleep: (ms) => sleepUntilStopped(ms),
6
7
  };
8
+ async function sleepUntilStopped(ms) {
9
+ if (runStopped()) {
10
+ return;
11
+ }
12
+ const controller = new AbortController();
13
+ const forget = onStop(() => controller.abort());
14
+ try {
15
+ await delay(ms, undefined, { signal: controller.signal });
16
+ }
17
+ catch {
18
+ }
19
+ finally {
20
+ forget();
21
+ }
22
+ }
7
23
  export function pause(clock, options, rest) {
8
24
  return clock.sleep(timerMs(Math.min(secondsToMs(options.intervalSeconds), rest)));
9
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "6.6.48",
3
+ "version": "6.6.49",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",