Skip to content

Commit 13fafa6

Browse files
committed
🐛 Write the syntax catalog whole, and state the CLI tier's commit identity (#643)
Two failures, both revealed rather than caused by the previous commit: the stale publish workflow had been killing all nine `test-deno` shards before a test ran, so nothing underneath it had been reported yet. ## The catalog was truncated when stdout was a pipe `process.stdout` is synchronous for a file or a terminal and asynchronous for a pipe, and the `syntax` case handed its whole document to `write` without waiting. The run then ended and the process exited with most of the document still in a buffer, so `xmd syntax --json > file` was whole at 89252 bytes while `xmd syntax --json | …` stopped at 65394 — inside a token, which is why the reader saw "Unexpected end of JSON input" rather than a short catalog. This became visible now because this branch registers the repository vocabulary in the catalog, which is what first pushed it past the buffer. The write now waits for the callback, so it finishes before anything can exit. Only that one write is changed. The other large writes in this file stream in chunks rather than handing over a single document, and none of them is near the buffer. ## The CLI tier read the host's Git identity `runOrdinary` installed the provider without saying who a commit is by, so it fell through to the production default — the caller's own `git config`. ORC18 and ORC15 therefore asserted something about who ran them: green on a machine with `user.name` set, `UnresolvedGitIdentityError` on every runner. It now states a fixture identity, the same correction the workflow tier already carries. ORC19 was never affected: it commits inside a subprocess whose environment it builds itself. Verified against a reproduced runner rather than a reading — with `user.useConfigOnly` set and no configuration file, the four CLI suites pass 11/33, and the npm-bin suite passes 1/2 with a rebuilt package.
1 parent f2ca658 commit 13fafa6

2 files changed

Lines changed: 38 additions & 3 deletions

File tree

‎packages/cli/src/cli.ts‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2429,7 +2429,7 @@ function* dispatch(
24292429
yield* exit(1);
24302430
break;
24312431
}
2432-
process.stdout.write(rendered);
2432+
yield* writeStdoutWhole(rendered);
24332433
break;
24342434
}
24352435
case "test-agent":
@@ -2530,6 +2530,27 @@ function* dispatch(
25302530
}
25312531
}
25322532

2533+
/**
2534+
* Write to stdout and wait for it to reach the operating system.
2535+
*
2536+
* `process.stdout` is asynchronous when it is a pipe and synchronous when it is
2537+
* a file or a terminal. A large document handed to `write` is therefore still
2538+
* sitting in a buffer when the run ends, and the process exits without it:
2539+
* `xmd syntax --json > file` is whole, `xmd syntax --json | jq` stops at about
2540+
* 64 KiB, in the middle of a token. Waiting for the callback is what makes the
2541+
* write finish before anything can exit.
2542+
*
2543+
* Only the catalog goes through this today, because it is the one output this
2544+
* command writes in a single call and the only one already past the buffer.
2545+
*/
2546+
function* writeStdoutWhole(text: string): Operation<void> {
2547+
yield* until(
2548+
new Promise<void>((resolve, reject) => {
2549+
process.stdout.write(text, (error) => (error ? reject(error) : resolve()));
2550+
}),
2551+
);
2552+
}
2553+
25332554
export function* runXmd(
25342555
args: string[],
25352556
installService: HostServiceInstaller,

‎packages/cli/tests/run-composition-deno.test.ts‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,14 @@ function* useAmbient(
9393
return { checkout, root: join(managed, "repositories"), home };
9494
}
9595

96-
/** Run one document under the ordinary provider, on a stream a caller chose. */
96+
/**
97+
* Run one document under the ordinary provider, on a stream a caller chose.
98+
*
99+
* The commit identity is stated rather than read from the host. The provider's
100+
* production default is the caller's own `git config`, so leaving it alone
101+
* makes `<Git.Commit>` refuse on any machine without `user.name` set — every CI
102+
* runner — and turns these cases into an assertion about who ran them.
103+
*/
97104
function runOrdinary(
98105
source: string,
99106
options: {
@@ -117,7 +124,14 @@ function runOrdinary(
117124
yield* useHostFiles();
118125
yield* installAgentComponents();
119126
yield* useCompositionComponents();
120-
yield* useRunComposition({ root: options.root, cwd: options.cwd });
127+
yield* useRunComposition({
128+
root: options.root,
129+
cwd: options.cwd,
130+
// deno-lint-ignore require-yield
131+
*identity(): Operation<string | undefined> {
132+
return "Fixture <[email protected]> 0 +0000";
133+
},
134+
});
121135
if (options.agent !== undefined) {
122136
yield* options.agent();
123137
}

0 commit comments

Comments
 (0)