The best way to control Claude Code, Codex and more from any computer or phone
feat(server,web,mobile): a host that drops because it froze now says why (#22213)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Theo Browne committed
Oct 20, 2026 at 02:09 UTC
d7bc3a2f49f0f8dd9d5441f2ee4f0377367bcd91
12 files changed
+286
-9
apps/mobile/src/features/connection/ConnectionEnvironmentRow.tsx
+12
-1
@@ -1,7 +1,7 @@
1
import * as Dialog from "../../components/ui/Dialog";
2
import { ConnectionTraceId } from "./ConnectionTraceId";
3
import { SymbolView } from "../../components/ui/AppSymbol";
4
-import { hasSavedBearerRoute } from "@t3tools/client-runtime/connection";
4
+import { hasSavedBearerRoute, hostFreezeNotice } from "@t3tools/client-runtime/connection";
5
import type { AtomCommandResult } from "@t3tools/client-runtime/state/runtime";
6
import { type EnvironmentId, resolveEnvironmentMachineKind } from "@t3tools/contracts";
7
import { useAtomValue } from "@effect/atom-react";
@@ -67,6 +67,9 @@ export function ConnectionEnvironmentRow(props: {
67
const statusLabel = connectionStatusLabel(props.environment);
68
const statusTraceId = enabled ? props.environment.connectionErrorTraceId : null;
69
const hasConnectionFailure = enabled && props.environment.connectionError !== null;
70
+ const freeze = enabled
71
+ ? hostFreezeNotice(props.environment.environmentLabel, serverConfig?.lastEventLoopStall)
72
+ : null;
73
const isRetrying =
74
enabled &&
75
(props.environment.connectionState === "connecting" ||
@@ -151,6 +154,14 @@ export function ConnectionEnvironmentRow(props: {
154
) : null}
155
</Text>
156
) : null}
157
+ {freeze ? (
158
+ <Text
159
+ className="text-xs text-warning-foreground"
160
+ numberOfLines={props.expanded ? undefined : 1}
161
+ >
162
+ {`${freeze.title}. ${freeze.description}`}
163
+ </Text>
164
+ ) : null}
165
</Pressable>
166
167
<ThemedSwitch
apps/server/src/observability/EventLoopMonitor.test.ts
+27
@@ -1,5 +1,6 @@
1
import * as NodeServices from "@effect/platform-node/NodeServices";
2
import { assert, describe, it } from "@effect/vitest";
3
+import * as Context from "effect/Context";
4
import * as Effect from "effect/Effect";
5
import * as FileSystem from "effect/FileSystem";
6
import * as Layer from "effect/Layer";
@@ -27,6 +28,8 @@ const stalled: EventLoopMonitor.EventLoopReadings = {
28
rssBytes: 1536 * 1024 * 1024,
29
heapUsedBytes: 512 * 1024 * 1024,
30
elapsedMs: 30_000,
31
+ loadAverage: 219.43,
32
+ cpuCount: 18,
33
};
34
const quiet: EventLoopMonitor.EventLoopReadings = { ...stalled, delayMaxNs: ms(2_950) };
35
@@ -81,6 +84,30 @@ describe("EventLoopMonitor", () => {
84
}),
85
);
86
87
+ it.effect("reports a long stall when a client connects, before the next timed sample", () =>
88
+ Effect.gen(function* () {
89
+ const long = { ...stalled, delayMaxNs: ms(13_000), activeMs: 13_000 };
90
+ const context = yield* monitor([quiet, stalled, long]);
91
+ const eventLoop = Context.get(context, EventLoopMonitor.EventLoopMonitor);
92
+ // The startup sample is skipped, so a connect before it reads nothing.
93
+ assert.isUndefined(yield* eventLoop.latestNoticeableStall);
94
+
95
+ yield* TestClock.adjust("30 seconds");
96
+ // Under 5 s: logged, but not worth telling a client about.
97
+ assert.isUndefined(yield* eventLoop.latestNoticeableStall);
98
+ assert.deepStrictEqual(yield* eventLoop.latestNoticeableStall, {
99
+ detectedAt: "1970-01-01T00:00:30.000Z",
100
+ durationMs: 12_000,
101
+ loadAverage: 219.4,
102
+ cpuCount: 18,
103
+ });
104
+
105
+ // Too old to explain a drop now.
106
+ yield* TestClock.adjust("301 seconds");
107
+ assert.isUndefined(yield* eventLoop.latestNoticeableStall);
108
+ }).pipe(Effect.scoped),
109
+ );
110
+
111
it.effect("exports the server's memory, CPU and event loop from each sample", () =>
112
Effect.gen(function* () {
113
yield* monitor([quiet, stalled]);
apps/server/src/observability/EventLoopMonitor.ts
+64
-7
@@ -1,14 +1,19 @@
1
-// @effect-diagnostics nodeBuiltinImport:off - only node:perf_hooks exposes the event loop delay histogram.
1
+// @effect-diagnostics nodeBuiltinImport:off - only node:perf_hooks exposes the event loop delay histogram, and node:os the load average.
2
+import * as NodeOS from "node:os";
3
import * as NodePerfHooks from "node:perf_hooks";
4
5
+import type { ServerEventLoopStall } from "@t3tools/contracts";
6
import { RotatingFileSink } from "@t3tools/shared/logging";
7
+import * as Context from "effect/Context";
8
import * as DateTime from "effect/DateTime";
9
import * as Effect from "effect/Effect";
10
import * as Layer from "effect/Layer";
11
import * as Metric from "effect/Metric";
12
import * as Path from "effect/Path";
13
+import * as Ref from "effect/Ref";
14
import * as Schema from "effect/Schema";
15
import type * as Scope from "effect/Scope";
16
+import * as Semaphore from "effect/Semaphore";
17
18
import * as ServerConfig from "../config.ts";
19
import * as Metrics from "./Metrics.ts";
@@ -21,6 +26,20 @@ const RESOLUTION_MS = 1000;
26
const STALL_THRESHOLD_MS = 2000;
27
const SAMPLE_INTERVAL = "30 seconds";
28
const STALL_LOG_MAX_BYTES = 256 * 1024;
29
+// Long enough that users felt it. Shorter stalls stay in the log only.
30
+const NOTICEABLE_STALL_MS = 5000;
31
+// Clients show what they get, so an old stall must not explain a new drop.
32
+const NOTICEABLE_STALL_MAX_AGE_MS = 5 * 60_000;
33
+
34
+export class EventLoopMonitor extends Context.Reference<{
35
+ /**
36
+ * The latest stall of 5 s or more, if seen in the last 5 minutes. It samples
37
+ * first, so a stall that ended just before a client reconnected is included.
38
+ */
39
+ readonly latestNoticeableStall: Effect.Effect<ServerEventLoopStall | undefined>;
40
+}>("t3/observability/EventLoopMonitor", {
41
+ defaultValue: () => ({ latestNoticeableStall: Effect.succeed(undefined) }),
42
+}) {}
43
44
/** Delay in ns, active time in ms, CPU in µs. */
45
export interface EventLoopReadings {
@@ -39,6 +58,9 @@ export interface EventLoopReadings {
58
readonly heapUsedBytes: number;
59
/** Wall time the readings cover. */
60
readonly elapsedMs: number;
61
+ /** One-minute load average, undefined on Windows. */
62
+ readonly loadAverage: number | undefined;
63
+ readonly cpuCount: number;
64
}
65
66
// Node skips the first gap after a reset, so a stall right at a sample boundary can be missed.
@@ -77,6 +99,9 @@ const makeNodeSampler = Effect.gen(function* () {
99
rssBytes: memory.rss,
100
heapUsedBytes: memory.heapUsed,
101
elapsedMs: nextSampledAt - sampledAt,
102
+ // Windows has no load average and reports 0, which a running process never sees elsewhere.
103
+ loadAverage: NodeOS.loadavg()[0] || undefined,
104
+ cpuCount: NodeOS.availableParallelism(),
105
};
106
histogram.reset();
107
elu = nextElu;
@@ -120,9 +145,16 @@ export const layerWith = (
145
makeSampler: Effect.Effect<Effect.Effect<EventLoopReadings>, never, Scope.Scope>,
146
stallLog: StallLogOptions,
147
) =>
123
- Layer.effectDiscard(
148
+ Layer.effect(
149
+ EventLoopMonitor,
150
Effect.gen(function* () {
151
const sample = yield* makeSampler;
152
+ // Clients sample on connect as well as the timer, and the sampler resets shared state.
153
+ const sampling = yield* Semaphore.make(1);
154
+ const warmedUp = yield* Ref.make(false);
155
+ const latestNoticeableStall = yield* Ref.make<
156
+ { readonly stall: ServerEventLoopStall; readonly detectedAtMs: number } | undefined
157
+ >(undefined);
158
const stallSink = yield* Effect.try(
159
() =>
160
new RotatingFileSink({
@@ -143,7 +175,22 @@ export const layerWith = (
175
yield* recordGauges(readings);
176
const delayMaxMs = stallMs(readings);
177
if (delayMaxMs === undefined) return;
146
- const { utilization, usage, rssBytes } = readings;
178
+ const { utilization, usage, rssBytes, loadAverage, cpuCount } = readings;
179
+ const now = yield* DateTime.now;
180
+ const detectedAt = DateTime.formatIso(now);
181
+ if (delayMaxMs >= NOTICEABLE_STALL_MS) {
182
+ yield* Ref.set(latestNoticeableStall, {
183
+ detectedAtMs: DateTime.toEpochMillis(now),
184
+ stall: {
185
+ detectedAt,
186
+ durationMs: delayMaxMs,
187
+ ...(loadAverage === undefined
188
+ ? {}
189
+ : { loadAverage: Math.round(loadAverage * 10) / 10 }),
190
+ cpuCount,
191
+ },
192
+ });
193
+ }
194
const attributes = {
195
delayMaxMs,
196
utilization: Math.round(utilization * 100) / 100,
@@ -158,8 +205,7 @@ export const layerWith = (
205
Effect.withSpan("server.eventLoop.stall", { root: true, level: "Warn", attributes }),
206
);
207
if (stallSink !== undefined) {
161
- const time = DateTime.formatIso(yield* DateTime.now);
162
- yield* encodeStallLine({ time, ...attributes }).pipe(
208
+ yield* encodeStallLine({ time: detectedAt, ...attributes }).pipe(
209
Effect.flatMap((line) => Effect.try(() => stallSink.write(`${line}\n`))),
210
Effect.catch(() =>
211
Effect.logWarning("event loop stall log write failed", {
@@ -168,17 +214,28 @@ export const layerWith = (
214
),
215
);
216
}
171
- });
217
+ }).pipe(sampling.withPermits(1));
218
const wait = Effect.sleep(SAMPLE_INTERVAL);
219
// The layer builds before the rest of the server, so the first sample covers
220
// startup work such as migrations and projection bootstrap. That can block the
221
// loop for seconds on a large database, so skip it rather than warn at every
222
// launch.
223
yield* wait.pipe(
178
- Effect.andThen(sample),
224
+ Effect.andThen(sampling.withPermits(1)(sample)),
225
+ Effect.andThen(Ref.set(warmedUp, true)),
226
Effect.andThen(wait.pipe(Effect.andThen(tick), Effect.forever)),
227
Effect.forkScoped,
228
);
229
+
230
+ return EventLoopMonitor.of({
231
+ latestNoticeableStall: Effect.gen(function* () {
232
+ if (yield* Ref.get(warmedUp)) yield* tick;
233
+ const latest = yield* Ref.get(latestNoticeableStall);
234
+ if (latest === undefined) return undefined;
235
+ const ageMs = DateTime.toEpochMillis(yield* DateTime.now) - latest.detectedAtMs;
236
+ return ageMs <= NOTICEABLE_STALL_MAX_AGE_MS ? latest.stall : undefined;
237
+ }),
238
+ });
239
}),
240
);
241
apps/server/src/ws.ts
+4
@@ -214,6 +214,7 @@ import * as ServerEnvironment from "./environment/ServerEnvironment.ts";
214
import * as DirectEndpoints from "./environment/DirectEndpoints.ts";
215
import * as RemoteOpenTargets from "./environment/RemoteOpenTargets.ts";
216
import * as DefectReporter from "./observability/DefectReporter.ts";
217
+import * as EventLoopMonitor from "./observability/EventLoopMonitor.ts";
218
import * as BackgroundPolicy from "./background/BackgroundPolicy.ts";
219
import * as EnvironmentAuth from "./auth/EnvironmentAuth.ts";
220
import { requiredScopeForDeviceList, rpcAuthorizationError } from "./auth/RpcAuthorization.ts";
@@ -1202,6 +1203,7 @@ export const layerWsRpc = (
1203
const projectStore = yield* ProjectStore.ProjectStoreV2;
1204
const projectService = yield* ProjectService.ProjectService;
1205
const managedFolders = yield* ManagedProjectFolders.ManagedProjectFolders;
1206
+ const eventLoopMonitor = yield* EventLoopMonitor.EventLoopMonitor;
1207
const threadSearch = yield* ThreadSearch.ThreadSearch;
1208
1209
const providerSessionsV2 = yield* ProviderSessionManager.ProviderSessionManagerV2;
@@ -1679,6 +1681,7 @@ export const layerWsRpc = (
1681
const environment = yield* serverEnvironment.getDescriptor;
1682
const auth = yield* serverAuth.getDescriptor();
1683
const scratchWorkspaceRoot = yield* managedFolders.scratchRoot;
1684
+ const lastEventLoopStall = yield* eventLoopMonitor.latestNoticeableStall;
1685
const editorConfig = yield* resolveEditorConfig(
1686
yield* resolveAvailableEditorsForConfig(externalLauncher.resolveAvailableEditors()),
1687
resolveFileManagerRevealKindForConfig(externalLauncher.resolveFileManagerRevealKind()),
@@ -1720,6 +1723,7 @@ export const layerWsRpc = (
1723
onSome: (root) => ({ scratchWorkspaceRoot: root }),
1724
}),
1725
newProjectsRoot: managedFolders.namedProjectsRoot,
1726
+ ...(lastEventLoopStall === undefined ? {} : { lastEventLoopStall }),
1727
};
1728
});
1729
apps/web/src/components/HostFreezeToastCoordinator.tsx
new
+33
@@ -0,0 +1,33 @@
1
+import { useAtomValue } from "@effect/atom-react";
2
+import { hostFreezeNotice } from "@t3tools/client-runtime/connection";
3
+import { useEffect, useRef } from "react";
4
+
5
+import { environmentSummaries } from "../state/presentation";
6
+import { environmentServerConfigsAtom } from "../state/server";
7
+import { toastManager } from "./ui/toast";
8
+
9
+/** Tells the user why a host dropped, once per stall, when it reports one on reconnect. */
10
+export function HostFreezeToastCoordinator() {
11
+ const configs = useAtomValue(environmentServerConfigsAtom);
12
+ const identities = useAtomValue(environmentSummaries.identitiesAtom);
13
+ const shownRef = useRef(new Set<string>());
14
+
15
+ useEffect(() => {
16
+ for (const [environmentId, config] of configs) {
17
+ const stall = config.lastEventLoopStall;
18
+ if (stall === undefined) continue;
19
+ const key = `${environmentId}:${stall.detectedAt}`;
20
+ if (shownRef.current.has(key)) continue;
21
+ shownRef.current.add(key);
22
+ const label =
23
+ identities.find((identity) => identity.environmentId === environmentId)?.label ??
24
+ config.environment.label;
25
+ const notice = hostFreezeNotice(label, stall);
26
+ if (notice !== null) {
27
+ toastManager.add({ type: "warning", ...notice });
28
+ }
29
+ }
30
+ }, [configs, identities]);
31
+
32
+ return null;
33
+}
apps/web/src/routes/__root.tsx
+2
@@ -37,6 +37,7 @@ import { ThreadNotificationCoordinator } from "../components/ThreadNotificationC
37
import { ReopenClosedViewShortcut } from "../components/ReopenClosedViewShortcut";
38
import { ProjectCloneToastCoordinator } from "../components/ProjectCloneToastCoordinator";
39
import { PullRequestGuideRunCoordinator } from "../components/pullRequest/guide/PullRequestGuideRunCoordinator";
40
+import { HostFreezeToastCoordinator } from "../components/HostFreezeToastCoordinator";
41
import { SlowRpcRequestToastCoordinator } from "../components/SlowRpcRequestToastCoordinator";
42
import { ChatGptWelcomeCoordinator } from "../components/settings/ChatGptWelcomeCoordinator";
43
import { ProviderAuthCallbackCoordinator } from "../components/settings/ProviderAuthCallbackCoordinator";
@@ -243,6 +244,7 @@ function RootRouteView() {
244
<ConfirmDialogHost />
245
<CustomSnoozeDialogHost />
246
<SlowRpcRequestToastCoordinator />
247
+ <HostFreezeToastCoordinator />
248
<PermissionUpdateNotice />
249
{primaryEnvironmentAuthenticated ? <LegacyThreadMigrationToast /> : null}
250
<ProjectCloneToastCoordinator />
packages/client-runtime/src/connection/hostFreeze.test.ts
new
+26
@@ -0,0 +1,26 @@
1
+import { describe, expect, it } from "vite-plus/test";
2
+
3
+import { hostFreezeNotice } from "./hostFreeze.ts";
4
+
5
+const stall = {
6
+ detectedAt: "2026-10-20T07:50:37.633Z",
7
+ durationMs: 12_422,
8
+ loadAverage: 219.4,
9
+ cpuCount: 18,
10
+};
11
+
12
+describe("hostFreezeNotice", () => {
13
+ it("blames an overloaded CPU when the load is above the core count", () => {
14
+ expect(hostFreezeNotice("leftbook", stall)).toEqual({
15
+ title: "leftbook froze for 12s",
16
+ description: "Its CPU is overloaded (load 219 on 18 cores).",
17
+ });
18
+ });
19
+
20
+ it("blames T3 Code when the CPU had room, or the host reports no load", () => {
21
+ const busy = "T3 Code on leftbook was too busy to answer.";
22
+ expect(hostFreezeNotice("leftbook", { ...stall, loadAverage: 4 })?.description).toBe(busy);
23
+ const { loadAverage: _load, ...windows } = stall;
24
+ expect(hostFreezeNotice("leftbook", windows)?.description).toBe(busy);
25
+ });
26
+});
packages/client-runtime/src/connection/hostFreeze.ts
new
+25
@@ -0,0 +1,25 @@
1
+import type { ServerEventLoopStall } from "@t3tools/contracts";
2
+
3
+export interface HostFreezeNotice {
4
+ readonly title: string;
5
+ readonly description: string;
6
+}
7
+
8
+/**
9
+ * Says why a host stopped answering, from the recent stall it reports on
10
+ * connect. Web shows it as a toast, mobile in the environment's connection row.
11
+ */
12
+export function hostFreezeNotice(
13
+ hostLabel: string,
14
+ stall: ServerEventLoopStall | undefined,
15
+): HostFreezeNotice | null {
16
+ if (stall === undefined) return null;
17
+ const { loadAverage, cpuCount } = stall;
18
+ return {
19
+ title: `${hostLabel} froze for ${Math.round(stall.durationMs / 1000)}s`,
20
+ description:
21
+ loadAverage !== undefined && loadAverage > cpuCount
22
+ ? `Its CPU is overloaded (load ${Math.round(loadAverage)} on ${cpuCount} cores).`
23
+ : `T3 Code on ${hostLabel} was too busy to answer.`,
24
+ };
25
+}
packages/client-runtime/src/connection/index.ts
+1
@@ -5,6 +5,7 @@ export * as CredentialStore from "./credentialStore.ts";
5
export { type ConnectionDriverProgress, type EnvironmentConnectionLease } from "./driver.ts";
6
export * from "./errors.ts";
7
export * from "./githubRoutingPermissions.ts";
8
+export * from "./hostFreeze.ts";
9
export * as Connection from "./layer.ts";
10
export * from "./model.ts";
11
export * as ConnectionOnboarding from "./onboarding.ts";
packages/client-runtime/src/state/server.test.ts
+70
@@ -882,6 +882,76 @@ describe("server state projection", () => {
882
}),
883
);
884
885
+ it.effect("shows a reported stall but never caches it", () =>
886
+ Effect.gen(function* () {
887
+ const events = yield* Queue.unbounded<ServerConfigStreamEvent>();
888
+ const client = {
889
+ [WS_METHODS.subscribeServerConfig]: () => Stream.fromQueue(events),
890
+ } as unknown as WsRpcProtocolClient;
891
+ const supervisor = EnvironmentSupervisor.EnvironmentSupervisor.of({
892
+ target: TARGET,
893
+ state: yield* SubscriptionRef.make(AVAILABLE_CONNECTION_STATE),
894
+ session: yield* SubscriptionRef.make(Option.some(session(client))),
895
+ prepared: yield* SubscriptionRef.make(Option.none<PreparedConnection>()),
896
+ connect: Effect.void,
897
+ disconnect: Effect.void,
898
+ retryNow: Effect.void,
899
+ } satisfies EnvironmentSupervisor.EnvironmentSupervisor["Service"]);
900
+ const savedConfigs = yield* Queue.unbounded<ServerConfig>();
901
+ const cache = Persistence.EnvironmentCacheStore.of({
902
+ loadShell: () => Effect.succeedNone,
903
+ saveShell: () => Effect.void,
904
+ loadThread: () => Effect.succeedNone,
905
+ saveThread: () => Effect.void,
906
+ removeThread: () => Effect.void,
907
+ loadServerConfig: () => Effect.succeedSome(CONFIG),
908
+ saveServerConfig: (_environmentId, config) => Queue.offer(savedConfigs, config),
909
+ loadVcsRefs: () => Effect.succeedNone,
910
+ saveVcsRefs: () => Effect.void,
911
+ removeVcsRefs: () => Effect.void,
912
+ clearVcsRefs: () => Effect.void,
913
+ clear: () => Effect.void,
914
+ });
915
+
916
+ yield* Effect.scoped(
917
+ Effect.gen(function* () {
918
+ const state = yield* makeEnvironmentServerConfigState({}).pipe(
919
+ Effect.provideService(EnvironmentSupervisor.EnvironmentSupervisor, supervisor),
920
+ Effect.provideService(Persistence.EnvironmentCacheStore, cache),
921
+ );
922
+ expect(Option.getOrThrow(yield* SubscriptionRef.get(state)).config).toBe(CONFIG);
923
+
924
+ const lastEventLoopStall = {
925
+ detectedAt: "2026-10-20T07:50:37.633Z",
926
+ durationMs: 12_422,
927
+ loadAverage: 219.4,
928
+ cpuCount: 18,
929
+ };
930
+ yield* Queue.offer(events, {
931
+ version: 1,
932
+ type: "snapshot",
933
+ config: { ...CONFIG, lastEventLoopStall },
934
+ });
935
+ const projected = yield* SubscriptionRef.changes(state).pipe(
936
+ Stream.filter((value) =>
937
+ Option.match(value, {
938
+ onNone: () => false,
939
+ onSome: (projection) => projection.source === "live",
940
+ }),
941
+ ),
942
+ Stream.runHead,
943
+ );
944
+ expect(Option.getOrThrow(Option.getOrThrow(projected)).config.lastEventLoopStall).toEqual(
945
+ lastEventLoopStall,
946
+ );
947
+ }),
948
+ );
949
+
950
+ // Cached, it would read as a fresh freeze on the next launch.
951
+ expect(yield* Queue.take(savedConfigs)).not.toHaveProperty("lastEventLoopStall");
952
+ }),
953
+ );
954
+
955
it.effect("does not rewrite cached configuration when no live update arrives", () =>
956
Effect.gen(function* () {
957
const client = {
packages/client-runtime/src/state/server.ts
+3
-1
@@ -386,7 +386,9 @@ export const makeEnvironmentServerConfigState = Effect.fn("EnvironmentServerConf
386
const persist = Effect.fn("EnvironmentServerConfigState.persist")(function* (
387
config: ServerConfig,
388
) {
389
- return yield* cache.saveServerConfig(environmentId, withoutEnvironmentThemes(config)).pipe(
389
+ // A cached stall would read as a fresh freeze on the next launch.
390
+ const { lastEventLoopStall: _stall, ...cacheable } = withoutEnvironmentThemes(config);
391
+ return yield* cache.saveServerConfig(environmentId, cacheable).pipe(
392
Effect.as(true),
393
Effect.catch((error) =>
394
Effect.logWarning("Could not persist cached server configuration.").pipe(
packages/contracts/src/server.ts
+19
@@ -586,6 +586,19 @@ export const ServerDirectEndpoint = Schema.Struct({
586
});
587
export type ServerDirectEndpoint = typeof ServerDirectEndpoint.Type;
588
589
+/**
590
+ * A stretch where the server's event loop could not run, so it answered
591
+ * nothing and clients may have dropped the connection.
592
+ */
593
+export const ServerEventLoopStall = Schema.Struct({
594
+ detectedAt: IsoDateTime,
595
+ durationMs: NonNegativeInt,
596
+ /** One-minute load average when the stall was seen. Absent on Windows, which has none. */
597
+ loadAverage: Schema.optionalKey(Schema.Number),
598
+ cpuCount: PositiveInt,
599
+});
600
+export type ServerEventLoopStall = typeof ServerEventLoopStall.Type;
601
+
602
export const ServerConfig = Schema.Struct({
603
environment: ExecutionEnvironmentDescriptor,
604
auth: ServerAuthDescriptor,
@@ -616,6 +629,12 @@ export const ServerConfig = Schema.Struct({
629
threadFindProgressive: Schema.optionalKey(Schema.Boolean),
630
scratchWorkspaceRoot: Schema.optionalKey(TrimmedNonEmptyString),
631
newProjectsRoot: Schema.optionalKey(TrimmedNonEmptyString),
632
+ /**
633
+ * The latest stall long enough to notice, sent only for a few minutes after
634
+ * it. A client that reconnects reads it to say why the host stopped
635
+ * answering. Clients do not cache it, since it describes the host at connect.
636
+ */
637
+ lastEventLoopStall: Schema.optionalKey(ServerEventLoopStall),
638
/**
639
* Never sent in a config snapshot: the theme stream emits the current set
640
* before any change, so a snapshot carrying it too would hand every