Skip to content
This repository was archived by the owner on Oct 10, 2026. It is now read-only.

Commit 6e3b738

Browse files
authored
fix(server): bound editor discovery during config loading (pingdotgg#4291)
1 parent 5ba6ef7 commit 6e3b738

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

‎apps/server/src/server.test.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ const TEST_EPOCH = DateTime.makeUnsafe("1970-01-01T00:00:00.000Z");
7373

7474
import * as ServerConfig from "./config.ts";
7575
import { makeRoutesLayer } from "./server.ts";
76+
import { resolveAvailableEditorsForConfig } from "./ws.ts";
7677
import * as CheckpointDiffQuery from "./checkpointing/CheckpointDiffQuery.ts";
7778
import * as GitManager from "./git/GitManager.ts";
7879
import * as Keybindings from "./keybindings.ts";
@@ -3763,6 +3764,23 @@ it.layer(NodeServices.layer)("server router seam", (it) => {
37633764
}).pipe(Effect.provide(NodeHttpServer.layerTest)),
37643765
);
37653766

3767+
it.effect("does not block server config when editor discovery never resolves", () =>
3768+
Effect.gen(function* () {
3769+
const discoveryInterrupted = yield* Deferred.make<void>();
3770+
const responseFiber = yield* resolveAvailableEditorsForConfig(
3771+
Effect.never.pipe(
3772+
Effect.onInterrupt(() => Deferred.succeed(discoveryInterrupted, undefined)),
3773+
),
3774+
).pipe(Effect.forkChild);
3775+
3776+
yield* TestClock.adjust(Duration.seconds(5));
3777+
3778+
const availableEditors = yield* Fiber.join(responseFiber);
3779+
yield* Deferred.await(discoveryInterrupted);
3780+
assert.deepEqual(availableEditors, []);
3781+
}),
3782+
);
3783+
37663784
it.effect(
37673785
"rejects websocket rpc handshake when a session token is only provided via query string",
37683786
() =>

‎apps/server/src/ws.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,15 @@ import * as RelayClient from "@t3tools/shared/relayClient";
123123
const isOrchestrationDispatchCommandError = Schema.is(OrchestrationDispatchCommandError);
124124

125125
const nowIso = Effect.map(DateTime.now, DateTime.formatIso);
126+
const EDITOR_DISCOVERY_TIMEOUT = Duration.seconds(5);
127+
128+
export const resolveAvailableEditorsForConfig = <A, E, R>(
129+
discovery: Effect.Effect<ReadonlyArray<A>, E, R>,
130+
) =>
131+
discovery.pipe(
132+
Effect.timeoutOption(EDITOR_DISCOVERY_TIMEOUT),
133+
Effect.map(Option.getOrElse(() => [])),
134+
);
126135

127136
function unexpectedCompatibilityError(error: never): never {
128137
throw new Error(`Unhandled compatibility error: ${String(error)}`);
@@ -1087,7 +1096,9 @@ const makeWsRpcLayer = (
10871096
keybindings: keybindingsConfig.keybindings,
10881097
issues: keybindingsConfig.issues,
10891098
providers,
1090-
availableEditors: yield* externalLauncher.resolveAvailableEditors(),
1099+
availableEditors: yield* resolveAvailableEditorsForConfig(
1100+
externalLauncher.resolveAvailableEditors(),
1101+
),
10911102
observability: {
10921103
logsDirectoryPath: config.logsDir,
10931104
localTracingEnabled: true,

0 commit comments

Comments
 (0)