Skip to content

Commit 8d911d4

Browse files
committed
🤖 Verify the whole battery at once, and prove it changed nothing
The checks were always independent; what stopped them running together was shared mutable state, and #304 removed it. This is the command that uses that, and the rule that keeps it true. `deno task verify` starts every applicable check concurrently after one setup, reports them in a fixed order however they finish, prints the first failure's output complete and names the rest, and fails if the battery moved any tracked file's content, mode, symlink target, or presence — including when a command failed, which is when a dirtied tree would otherwise go unnoticed. The split is enforced rather than intended. `scripts/lib/verify.ts` decides what runs and what the report says and is listed in `tsconfig.node.json`, so importing the Deno-only `prepared-state.ts` fails the Node typecheck; `scripts/verify.ts` installs the host behaviour it needs. The harness guarantees complete, byte-exact, non-interleaved output and observed cleanup. It does not slow a child down: `@effectionx/node`'s `fromReadable` subscribes with `on("data")`, so a pipe drains regardless of the consumer. What the guarantee rests on is a sink that cannot fall behind — one that suspends is halted at teardown with its backlog queued and those bytes gone — so the spool writes synchronously, and a test fails if it ever yields. On an unprepared worktree the preflight refuses: a fixture adapter's sentinel is never written, no battery command starts, `deno.lock` is byte-identical, and the exit is non-zero naming `deno task setup`. What the task runner creates while resolving the workspace beforehand is neither required nor asserted. Running the battery concurrently exposed a defect it also fails on serially: a document under test writes its eval blocks to `.xmd-eval/*.ts`, and the workspace `deno check` type-checked them, so `check` broke whenever `docs` had a file in flight. That directory joins the `exclude` list. `verify:clean` now ends by running the battery once, and holds it to a different claim than a build. A build is cache-pure: `build:web`, `build`, and the release compile must leave `node_modules`, the cache's dependency content, and `deno.lock` byte-identical, and that comparison is unchanged. Verification is not cache-pure and does not claim to be — it resolves modules no build walks, the dnt graph behind `scripts/build-npm.ts` among them, so it adds to the Deno cache the runtime owns. What it may never move is what this repository owns, so its phase compares `node_modules` and the lockfile. Once, and `--no-site`. The battery wants four cores and a CI runner has four, so two of them thrash rather than overlap, and the two extra commands are what the `site` job already runs. The cold-refusal test lost its scratch `DENO_DIR` for the same reason — unprepared means the worktree, not the cache, so inheriting a warm one costs six seconds instead of twenty-eight and proves exactly as much. Their scratch repositories also pin identity *and signing* on the command line: inheriting a global config that signs through an external agent made `git commit` exit 128 whenever that agent was busy. `deno bundle` and the esbuild service it spawns deadlock under concurrent load: `esbuild_client`'s two bounded protocol channels fill on both sides under CPU starvation, its select loop and handler task each park in a send the other can never drain, and both processes idle at 0% CPU indefinitely. Filed upstream as denoland/deno#36417. Both `composability` runs hit it, hanging silently until cancelled an hour in, and it reproduced locally. Three ceilings turn that into bounded, reported failure: - `scripts/lib/retry.ts`: `retryStuck` halts an attempt that outlives its ceiling — tearing down the bundler pair — and runs a fresh one. `bundleClient` allows three 120s attempts; only a stuck attempt retries, a failing one still fails on the spot. - `scripts/lib/verify.ts`: every battery command races a 20-minute ceiling; a command settled by it reports `(timed out)` with everything it had written, and the rest of the battery still finishes. - `ci.yml`: `composability` gets `timeout-minutes: 60` as the job backstop. A halted build cannot orphan its esbuild service — the service exits on pipe EOF — and a live wedge held exactly one service, the stuck bundle's own child, so the halt-mid-bundle tests are unrelated and stay as they are. `composability` also gains the Bun the battery runs. The first battery ever to complete in that job failed only at `bun run test:bun`: at spawn, in zero seconds, with an empty spool, because the job never installed the runtime. That job now runs on `main` only. Measured on a full green run: it took the workflow's critical path from 434s to 649s, and 1,420s of what it does inside that is the Deno, Node, and Bun suites — which `test-deno`, `test-node`, and `test-bun` already run in parallel, on their own runners. Compressing them onto one four-core runner buys contention, not overlap. What the job uniquely proves — that a clean checkout prepares, that builds stay cache-pure and offline, and that concurrent checks do not dirty what another reads — is a property of installation that most changes cannot break, so it is worth a post-merge run rather than a place on every pull request's critical path. Running the battery concurrently exposed one more collision, of exactly the kind the rule forbids: `deno task test` builds the npm packages into `packages/*/npm`, and `lint` read that output while it was being written — oxlint's `import` plugin resolving through the `node_modules` dnt puts there, oxfmt format-checking generated files. It failed roughly one run in twelve, and reproducibly within two iterations of a lint loop run beside the npm build. That output now sits behind the lint task's ignore patterns, beside the fixtures and for the same reason: an `ignorePatterns` entry in `.oxlintrc.json` stops the rule tests seeing their own fixtures, so both exclusions live on the command line. `deno check` reads that same output, so `**/npm` joins `.xmd-eval` in the workspace `exclude` on the same grounds: both are generated, both are rewritten by a command running beside the one reading them, and type-checking either mid-write fails the whole workspace for a file nobody committed. Closes #279
1 parent 6bfe6a6 commit 8d911d4

21 files changed

Lines changed: 2121 additions & 39 deletions

‎.github/workflows/ci.yml‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,19 @@ jobs:
243243
# whole chain end to end rather than each link separately.
244244
composability:
245245
runs-on: ubuntu-latest
246+
# `main` only. The battery this job runs spends ~1,420s on the Deno, Node,
247+
# and Bun suites — which `test-deno`, `test-node`, and `test-bun` already
248+
# run in parallel, on their own runners. Compressing them onto one four-core
249+
# runner made the workflow's critical path 434s → 649s to prove a property
250+
# about installation that most changes cannot break. What this job uniquely
251+
# proves — a clean checkout prepares, builds stay cache-pure and offline,
252+
# and concurrent checks do not dirty what another reads — is worth a
253+
# post-merge run, not a place on every pull request's critical path (#279).
254+
if: github.event_name == 'push'
255+
# A wedged `deno bundle` ↔ esbuild pair inside the battery would otherwise
256+
# hang this job to the six-hour default with nothing printed. The battery
257+
# itself settles a stuck command at 20 minutes; this is the backstop.
258+
timeout-minutes: 60
246259
steps:
247260
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
248261

@@ -252,6 +265,13 @@ jobs:
252265

253266
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4
254267

268+
# The battery this job runs includes `bun run test:bun`; without the
269+
# runtime that command fails at spawn, in zero seconds, with an empty
270+
# spool.
271+
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
272+
with:
273+
bun-version: 1.3.14
274+
255275
- uses: denoland/setup-deno@e95548e56dfa95d4e1a28d6f422fafe75c4c26fb # v2.0.3
256276
with:
257277
deno-version: v2.9.1

‎.oxfmtrc.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22
// Markdown is source code here: oxfmt reindents fenced blocks and rewrites
33
// `yield*` as `yield *`, which changes what a document does. Fixtures carry
44
// the exact indentation the rule tests assert on.
5-
"ignorePatterns": ["**/*.md", "scripts/tests/fixtures/**"]
5+
// `packages/*/npm` is generated dnt output, written by a test while the
6+
// battery runs; format-checking it fails on a file nobody wrote by hand.
7+
"ignorePatterns": ["**/*.md", "scripts/tests/fixtures/**", "**/npm/**"]
68
}

‎AGENTS.md‎

Lines changed: 57 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,51 @@ representative release target and proves the host tree and lock survived it,
4848
then runs every build phase offline — including a release compile for
4949
`x86_64-unknown-linux-gnu`, the same shape `release.yml` uses — fingerprinting
5050
the content and modes of `node_modules`, the cache's dependency roots, and
51-
`deno.lock` after each one. It verifies the commit, so commit before running it.
52-
CI runs the same harness in its `composability` job.
51+
`deno.lock` after each one. It then runs the battery itself, once.
52+
53+
Builds and checks are held to different claims there. A build is cache-pure:
54+
nothing it does may move `node_modules`, the cache's dependency content, or the
55+
lockfile. Verification is not, and does not pretend to be — the battery resolves
56+
modules no build walks, so it adds to the Deno cache, which the runtime owns.
57+
What verification may never move is what this repository owns: tracked files,
58+
`node_modules`, `deno.lock`, and another invocation's temporary state.
59+
60+
It verifies the commit, so commit before running it. CI runs the same harness in
61+
its `composability` job — **on `main` only**. The battery it runs spends most of
62+
its time on the three runtime suites, which `test-deno`, `test-node`, and
63+
`test-bun` already run in parallel on their own runners, so putting it on every
64+
pull request bought a 50% longer critical path and no new information. Run it
65+
locally before you push anything that could move dependency state; on `main` it
66+
is the post-merge proof, and a failure there opens a `ci-main-red` issue.
5367

5468
## Verification
5569

56-
After making any changes to source files (`src/`) or test files (`tests/`),
57-
always run all four checks before committing:
70+
One command runs everything that applies, concurrently:
71+
72+
```bash
73+
deno task verify # add --no-site to skip the site pair
74+
```
75+
76+
**The whole applicable battery is designed to run at once, after one setup.**
77+
That is a repository rule, not a convenience: no check may install, relink,
78+
patch, chmod, or clean a path another check reads, and any temporary state a
79+
check needs belongs to that invocation alone. A helper that reaches for
80+
repository-wide mutable state breaks every other check running beside it, which
81+
is how a `deno task build` came to break the Node typecheck (#279).
82+
83+
`verify` reports every command in a fixed order however they finish, prints the
84+
first failure's output complete and names the rest, and fails if the battery
85+
moved any tracked file's content, mode, symlink target, or presence — including
86+
when a command failed, because that is when a dirtied tree would otherwise go
87+
unnoticed. **Capture a failure's first output before re-running anything**: the
88+
report is what you paste, and a second run can hide the first.
89+
90+
The site pair applies when `site/` changed, judged from the branch and the
91+
worktree, both sides of a rename included.
92+
93+
Running the checks individually is still fine, and is what `verify` does for
94+
you. After making any changes to source files (`src/`) or test files (`tests/`),
95+
always run all four before committing:
5896

5997
1. **Lint + Format**: `deno task lint` (runs `oxlint` + `oxfmt --check`) — must
6098
produce 0 errors. Run `deno task fmt` to auto-fix formatting.
@@ -71,7 +109,13 @@ here:
71109

72110
- `check`, `test`, and `check:jsr` follow the `packages/*` workspace glob in the
73111
root `deno.json`. Its `exclude` list holds the paths that must stay
74-
unchecked — currently the deliberately-malformed `scripts/tests/fixtures`.
112+
unchecked: the deliberately-malformed `scripts/tests/fixtures`; `.xmd-eval`,
113+
where a running document writes the `.ts` files its eval blocks compile to;
114+
and `**/npm`, the dnt build's output, which a test rewrites while the battery
115+
runs. All three are generated and belong to whichever command is producing
116+
them — type-checking one mid-write fails on a partial file, and fails the
117+
whole workspace check for a file nobody committed. The same output is skipped
118+
by `lint` and `fmt`, for the same reason.
75119
- `test:node` and `test:bun` derive the same corpus through
76120
`scripts/lib/test-files.ts`, which walks `tests/` beneath each workspace
77121
member plus `scripts/tests/` — that boundary, and nothing else. A new
@@ -89,10 +133,14 @@ here:
89133
- `lint` and `fmt` are defined once, as `package.json` scripts that `deno task`
90134
also exposes, and cover `packages` and `scripts`. Oxfmt skips Markdown
91135
(`.oxfmtrc.json`): these documents are executable, and reformatting a fenced
92-
block changes what they do. The fixtures stay out of both, on the lint task's
93-
command line rather than in `.oxlintrc.json` — the rule tests in
94-
`scripts/tests/` lint those same files through the repository config and need
95-
it to keep reporting on them.
136+
block changes what they do. `packages/*/npm` — the dnt build's output, which
137+
a test writes while the battery runs — is skipped by both: it is generated,
138+
gitignored, and carries a `node_modules` of its own that oxlint's `import`
139+
plugin resolves through, so linting it reports on half-written files nobody
140+
committed. The fixtures and that output stay out of `.oxlintrc.json`, on the
141+
lint task's command line instead — the rule tests in `scripts/tests/` lint
142+
through the repository config, and an `ignorePatterns` entry there stops them
143+
seeing their own fixtures.
96144

97145
## MUST READ
98146

‎README.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,14 @@ deno task build # compile the standalone xmd bi
242242
deno task lint # oxlint + oxfmt
243243
deno task check # typecheck
244244
deno task test # run the test suite
245+
deno task verify # the whole applicable battery, concurrently
245246
```
246247

247248
`deno task setup` is the only thing that installs. Builds and checks read what
248249
it prepared and write nothing back, so they compose instead of undoing one
249-
another — `deno task verify:clean` runs that claim end to end against a clean
250-
clone (AGENTS.md).
250+
another: `deno task verify` starts the entire applicable battery at once and
251+
fails if any of it leaves a tracked file changed, and `deno task verify:clean`
252+
runs that claim end to end against a clean clone (AGENTS.md).
251253

252254
## Status
253255

‎deno.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"workspace": ["packages/*", "site"],
3-
"exclude": ["scripts/tests/fixtures"],
3+
"exclude": ["scripts/tests/fixtures", ".xmd-eval", "**/npm"],
44
"nodeModulesDir": "auto",
55
"lock": {
66
"frozen": true
@@ -51,6 +51,7 @@
5151
"gen:publish-workflow": "deno run --allow-all packages/cli/src/deno.ts run scripts/gen-publish-workflow.md",
5252
"bump": "deno run -A scripts/bump-version.ts",
5353
"test": "deno test --allow-all --frozen",
54+
"verify": "deno run --allow-all --node-modules-dir=none --cached-only --frozen scripts/preflight.ts scripts/verify.ts",
5455
"check": "deno check --frozen",
5556
"check:jsr": "deno publish --dry-run --allow-dirty",
5657
"review": "deno run --allow-all packages/cli/src/deno.ts run .reviews/ReviewPR.md --component-dir .reviews/components --component-dir .reviews/policies --component-dir packages/core/components -j .reviews/journal.jsonl",

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"test:node": "tsx scripts/runtime-tests.ts node",
7171
"test:bun": "bun scripts/runtime-tests.ts bun",
7272
"test:deno": "deno task test",
73-
"lint": "oxlint -c .oxlintrc.json --ignore-pattern 'scripts/tests/fixtures/**' packages scripts && oxfmt --check packages scripts",
73+
"lint": "oxlint -c .oxlintrc.json --ignore-pattern 'scripts/tests/fixtures/**' --ignore-pattern '**/npm/**' packages scripts && oxfmt --check packages scripts",
7474
"fmt": "oxfmt --write packages scripts"
7575
},
7676
"workspaces": [

‎scripts/build-web-client.ts‎

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ import { resolve } from "node:path";
6969
import { pathToFileURL } from "node:url";
7070

7171
import { assertSideEffectFree, sideEffectFreeManifests } from "./lib/side-effect-free.ts";
72+
import { retryStuck } from "./lib/retry.ts";
7273
import { byteLength, generatedModule } from "./lib/web-client-module.ts";
7374

7475
const repoRoot = new URL("../", import.meta.url);
@@ -116,22 +117,37 @@ function* run(command: string, args: string[]): Operation<void> {
116117
yield* exec(command, { arguments: args, cwd: new URL(repoRoot).pathname }).expect();
117118
}
118119

120+
/**
121+
* A wedged bundler pair sits at 0% CPU forever (see `lib/retry.ts`), so the
122+
* ceiling only has to clear the slowest healthy bundle — ~1s alone, well
123+
* under a minute even inside the concurrent battery. Halting the attempt
124+
* kills the pair: the esbuild service exits when its parent's pipe closes,
125+
* which the halt-mid-bundle test observes.
126+
*/
127+
const BUNDLE_STUCK_MILLISECONDS = 120_000;
128+
const BUNDLE_ATTEMPTS = 3;
129+
119130
function* bundleClient(scratch?: string): Operation<string> {
120131
return yield* scoped(function* () {
121132
const output = yield* until(Deno.makeTempFile({ dir: scratch, suffix: ".js" }));
122133
yield* ensure(() => rm(output));
123-
yield* run(Deno.execPath(), [
124-
"bundle",
125-
"--platform=browser",
126-
"--minify",
127-
"--packages=bundle",
128-
"--node-modules-dir=manual",
129-
"--no-remote",
130-
"--frozen",
131-
"--output",
132-
output,
133-
CLIENT_ENTRY,
134-
]);
134+
yield* retryStuck(
135+
"deno bundle",
136+
() =>
137+
run(Deno.execPath(), [
138+
"bundle",
139+
"--platform=browser",
140+
"--minify",
141+
"--packages=bundle",
142+
"--node-modules-dir=manual",
143+
"--no-remote",
144+
"--frozen",
145+
"--output",
146+
output,
147+
CLIENT_ENTRY,
148+
]),
149+
{ milliseconds: BUNDLE_STUCK_MILLISECONDS, attempts: BUNDLE_ATTEMPTS },
150+
);
135151
return yield* readTextFile(output);
136152
});
137153
}

‎scripts/lib/changed-paths.ts‎

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
/**
2+
* Which paths this branch and worktree touched, from git's two answers.
3+
*
4+
* Verify asks one question of these: did anything under `site/` change? The
5+
* answer has to survive a rename, which is where the two sources stop agreeing.
6+
* Measured on this repository, renaming `site/page.md` to `moved-out.md`:
7+
*
8+
* ```text
9+
* git status --porcelain=v1 -z "R moved-out.md"\0"site/page.md"\0
10+
* ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^
11+
* status and NEW path share one field, then old
12+
*
13+
* git diff --name-status -z -M -C "R100"\0"site/page.md"\0"moved-out.md"\0
14+
* ^^^^^ ^^^^^^^^^^^^^ ^^^^^^^^^^^^
15+
* status OLD path new path
16+
* ```
17+
*
18+
* The path order is reversed between them, so one parser cannot read both.
19+
* Both paths are always yielded: a rename out of `site/` changes `site/` just
20+
* as much as a rename into it does.
21+
*
22+
* Two more shapes came out of the same measurements. An *unstaged* rename is
23+
* not reported as a rename at all — git emits ` D site/page.md` and
24+
* `?? moved-out.md` — so nothing here may assume an `R` exists. And a copy does
25+
* reach porcelain when `status.renames=copies` is configured
26+
* (`C site/copy2.md\0keep.md\0`), so `C` is read, not guessed at.
27+
*
28+
* A status neither parser recognises raises. Reading one path where git meant
29+
* two would silently drop the side that mattered.
30+
*/
31+
32+
export class ChangedPathsError extends Error {}
33+
34+
/** Every status letter git may put in a porcelain field or a name-status record. */
35+
const STATUS_LETTERS = new Set([" ", "M", "A", "D", "R", "C", "U", "T", "X", "B", "?", "!"]);
36+
37+
function fields(output: string): string[] {
38+
return output.split("\0").filter((field) => field.length > 0);
39+
}
40+
41+
function known(letter: string): boolean {
42+
return STATUS_LETTERS.has(letter);
43+
}
44+
45+
/**
46+
* Paths from `git status --porcelain=v1 -z`.
47+
*
48+
* The status is a fixed two-character prefix, not a split: `slice(0, 2)` and
49+
* `slice(3)`, because a path may itself contain spaces.
50+
*/
51+
export function parsePorcelain(output: string): string[] {
52+
const parts = fields(output);
53+
const paths: string[] = [];
54+
let index = 0;
55+
while (index < parts.length) {
56+
const record = parts[index]!;
57+
index += 1;
58+
const status = record.slice(0, 2);
59+
const [staged, worktree] = [status[0]!, status[1]!];
60+
if (!known(staged) || !known(worktree)) {
61+
throw new ChangedPathsError(
62+
`git status reported \`${status}\`, which this parser cannot read`,
63+
);
64+
}
65+
paths.push(record.slice(3));
66+
if (staged === "R" || staged === "C" || worktree === "R" || worktree === "C") {
67+
const origin = parts[index];
68+
if (origin === undefined) {
69+
throw new ChangedPathsError(`git status reported \`${status}\` without its second path`);
70+
}
71+
index += 1;
72+
paths.push(origin);
73+
}
74+
}
75+
return paths;
76+
}
77+
78+
/** Paths from `git diff --name-status -z -M -C`. */
79+
export function parseNameStatus(output: string): string[] {
80+
const parts = fields(output);
81+
const paths: string[] = [];
82+
let index = 0;
83+
while (index < parts.length) {
84+
const status = parts[index]!;
85+
index += 1;
86+
const letter = status[0]!;
87+
if (!known(letter)) {
88+
throw new ChangedPathsError(`git diff reported \`${status}\`, which this parser cannot read`);
89+
}
90+
const wanted = letter === "R" || letter === "C" ? 2 : 1;
91+
for (let taken = 0; taken < wanted; taken += 1) {
92+
const path = parts[index];
93+
if (path === undefined) {
94+
throw new ChangedPathsError(`git diff reported \`${status}\` without ${wanted} paths`);
95+
}
96+
index += 1;
97+
paths.push(path);
98+
}
99+
}
100+
return paths;
101+
}
102+
103+
/** Whether any changed path lies under `directory`. */
104+
export function touches(paths: string[], directory: string): boolean {
105+
const prefix = directory.endsWith("/") ? directory : `${directory}/`;
106+
return paths.some((path) => path.startsWith(prefix));
107+
}

‎scripts/lib/retry.ts‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { Err, Ok, race, sleep } from "effection";
2+
import type { Operation, Result } from "effection";
3+
4+
/** How long one attempt may run, and how many attempts there are. */
5+
export interface RetryStuckOptions {
6+
milliseconds: number;
7+
attempts: number;
8+
}
9+
10+
function* settled<T>(operation: () => Operation<T>): Operation<Result<T>> {
11+
return Ok(yield* operation());
12+
}
13+
14+
function* expired<T>(subject: string, milliseconds: number): Operation<Result<T>> {
15+
yield* sleep(milliseconds);
16+
return Err(new Error(`${subject} was still running after ${milliseconds}ms`));
17+
}
18+
19+
/**
20+
* Run `operation`; if it is still running when the ceiling passes, halt it —
21+
* tearing down everything it started — and run a fresh one, up to `attempts`
22+
* times in all.
23+
*
24+
* This retries only an operation that never settles. One that fails has
25+
* decided, and its error propagates on the spot.
26+
*
27+
* It exists for `deno bundle`: under concurrent load the bundler and the
28+
* esbuild service it spawns can lose their protocol handshake and wait on
29+
* each other forever, both at 0% CPU (denoland/deno#36417 — esbuild_client's
30+
* bounded protocol channels mutually fill). No observed wedge ever resolved
31+
* itself, so an attempt that outlives a generous ceiling is stuck, not slow
32+
* — and a fresh attempt is overwhelmingly likely to succeed.
33+
*/
34+
export function* retryStuck<T>(
35+
subject: string,
36+
operation: () => Operation<T>,
37+
{ milliseconds, attempts }: RetryStuckOptions,
38+
): Operation<T> {
39+
for (let attempt = 1; attempt < attempts; attempt++) {
40+
const result = yield* race([settled(operation), expired<T>(subject, milliseconds)]);
41+
if (result.ok) {
42+
return result.value;
43+
}
44+
}
45+
const last = yield* race([settled(operation), expired<T>(subject, milliseconds)]);
46+
if (last.ok) {
47+
return last.value;
48+
}
49+
throw new Error(
50+
`${subject} did not finish within ${milliseconds}ms in any of ${attempts} attempts`,
51+
);
52+
}

0 commit comments

Comments
 (0)