Skip to content

Commit bfb447f

Browse files
cliffhallclaude
andcommitted
fix: handle failed simulated sends; correct two comments
- everything's simulated logging and resource-update sends (immediate and interval) now log a rejected send instead of discarding it, so a closed transport cannot produce an unhandled rejection. - everything's tsconfig.test.json comment no longer claims its build config excludes the tests. - verify:dep-lockstep's wording now matches its rule: no two declarations may disagree; a single declaration anywhere is one range. Refs #4864 Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: cliffhall <[email protected]>
1 parent 11bd7a2 commit bfb447f

5 files changed

Lines changed: 34 additions & 19 deletions

File tree

‎scripts/verify-dep-lockstep.mjs‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515
//
1616
// So the rule is the smaller one §2.3 of docs/agent-guidance-inception.md
1717
// sets: every SHARED toolchain package is declared with ONE range everywhere it
18-
// is declared — across the root and every workspace, in any dependency section
19-
// — or declared only once (hoisted to the root). The shared set is named
18+
// is declared — across the root and every workspace, in any dependency section.
19+
// Declaring it in a single manifest (the root, as `prettier` is) is the
20+
// degenerate case of the same rule: one declaration is one range. Where a
21+
// package is declared is not this guard's question — only that no two
22+
// declarations disagree. The shared set is named
2023
// below. The Python servers are independent by design and have no manifest
2124
// here, so they are out of scope.
2225
//
@@ -119,7 +122,7 @@ export function main() {
119122
);
120123
for (const p of problems) console.error(` ${p}`);
121124
console.error(
122-
"\nDeclare each with one identical range everywhere it is declared, or only once at the root.",
125+
"\nDeclare each with one identical range everywhere it is declared (or in a single manifest).",
123126
);
124127
console.error(
125128
"Bump it in every manifest in the same change, then `npm install` at the root so the lockfile follows.",

‎scripts/verify-dep-lockstep.test.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ test("lockstep: one range everywhere passes", () => {
3434
);
3535
});
3636

37-
test("lockstep: declared only once (hoisted to the root) passes", () => {
37+
test("lockstep: a single declaration (e.g. only at the root) passes", () => {
3838
assert.deepEqual(
3939
lockstepProblems([
4040
{ dir: ".", pkg: { devDependencies: { prettier: "3.8.4" } } },

‎src/everything/resources/subscriptions.ts‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,21 @@ export const beginSimulatedResourceUpdates = (
138138
sessionId: string | undefined,
139139
) => {
140140
if (!subsUpdateIntervals.has(sessionId)) {
141-
// Send once immediately. Fire-and-forget: this function is synchronous by
142-
// contract (its callers start a background simulation), exactly like the
143-
// interval callback below, so the caller cannot hold the promise.
144-
void sendSimulatedResourceUpdates(server, sessionId);
141+
// Send once immediately, then every 5 seconds. Fire-and-forget: this
142+
// function is synchronous by contract (its callers start a background
143+
// simulation), so neither send can be awaited. A send that fails (e.g. the
144+
// transport closed before the updates were stopped) is logged rather than
145+
// left to become an unhandled rejection.
146+
const send = () =>
147+
sendSimulatedResourceUpdates(server, sessionId).catch((error: unknown) =>
148+
console.error("Simulated resource update failed:", error),
149+
);
150+
void send();
145151

146152
// Set the interval to send later resource update notifications to this client
147153
subsUpdateIntervals.set(
148154
sessionId,
149-
setInterval(() => sendSimulatedResourceUpdates(server, sessionId), 5000),
155+
setInterval(() => void send(), 5000),
150156
);
151157
}
152158
};

‎src/everything/server/logging.ts‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,21 @@ export const beginSimulatedLogging = (
5252

5353
// Set the interval to send later logging messages to this client
5454
if (!logsUpdateIntervals.has(sessionId)) {
55-
// Send once immediately. Fire-and-forget: this function is synchronous by
56-
// contract (it starts a background simulation), exactly like the interval
57-
// callback below, so the caller cannot hold the promise.
58-
void sendSimulatedLoggingMessage(sessionId);
55+
// Send once immediately, then every 5 seconds. Fire-and-forget: this
56+
// function is synchronous by contract (it starts a background simulation),
57+
// so neither send can be awaited. A send that fails (e.g. the transport
58+
// closed before `stopSimulatedLogging`) is logged rather than left to
59+
// become an unhandled rejection.
60+
const send = () =>
61+
sendSimulatedLoggingMessage(sessionId).catch((error: unknown) =>
62+
console.error("Simulated logging message failed:", error),
63+
);
64+
void send();
5965

6066
// Send a randomly-leveled log message every 5 seconds
6167
logsUpdateIntervals.set(
6268
sessionId,
63-
setInterval(() => sendSimulatedLoggingMessage(sessionId), 5000),
69+
setInterval(() => void send(), 5000),
6470
);
6571
}
6672
};

‎src/everything/tsconfig.test.json‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
// The typecheck program for the whole workspace (#4864). `tsconfig.json` is
3-
// the build config and leaves the tests out, so tsc does not emit them into
4-
// `dist/`; this one adds them back without emitting anything. `npm run
5-
// typecheck` runs it, and it is the parser project the root ESLint config
6-
// uses, so what is linted and what is typechecked are the same file set.
2+
// The no-emit typecheck program for the whole workspace (#4864). Here the
3+
// build `tsconfig.json` already includes the tests; this file exists so every
4+
// workspace has the same `tsconfig.test.json` that `npm run typecheck` runs
5+
// and the root ESLint config uses as its parser project, so what is linted
6+
// and what is typechecked are the same file set in every server.
77
"extends": "./tsconfig.json",
88
"compilerOptions": {
99
"noEmit": true

0 commit comments

Comments
 (0)