fix(server): bound editor discovery during config loading (#4291)

This commit is contained in:
maria authored and GitHub committed 2026-07-27 21:18:55 +02:00
1 parent 5ba6ef7f84
commit 6e3b73884b
2 files changed
+30 -1

No files matched your search

+18
View File
@@ -73,6 +73,7 @@ const TEST_EPOCH = DateTime.makeUnsafe("1970-01-01T00:00:00.000Z");
import * as ServerConfig from "./config.ts";
import { makeRoutesLayer } from "./server.ts";
import { resolveAvailableEditorsForConfig } from "./ws.ts";
import * as CheckpointDiffQuery from "./checkpointing/CheckpointDiffQuery.ts";
import * as GitManager from "./git/GitManager.ts";
import * as Keybindings from "./keybindings.ts";
@@ -3763,6 +3764,23 @@ it.layer(NodeServices.layer)("server router seam", (it) => {
}).pipe(Effect.provide(NodeHttpServer.layerTest)),
);
it.effect("does not block server config when editor discovery never resolves", () =>
Effect.gen(function* () {
const discoveryInterrupted = yield* Deferred.make<void>();
const responseFiber = yield* resolveAvailableEditorsForConfig(
Effect.never.pipe(
Effect.onInterrupt(() => Deferred.succeed(discoveryInterrupted, undefined)),
),
).pipe(Effect.forkChild);
yield* TestClock.adjust(Duration.seconds(5));
const availableEditors = yield* Fiber.join(responseFiber);
yield* Deferred.await(discoveryInterrupted);
assert.deepEqual(availableEditors, []);
}),
);
it.effect(
"rejects websocket rpc handshake when a session token is only provided via query string",
() =>
+12 -1
View File
@@ -123,6 +123,15 @@ import * as RelayClient from "@t3tools/shared/relayClient";
const isOrchestrationDispatchCommandError = Schema.is(OrchestrationDispatchCommandError);
const nowIso = Effect.map(DateTime.now, DateTime.formatIso);
const EDITOR_DISCOVERY_TIMEOUT = Duration.seconds(5);
export const resolveAvailableEditorsForConfig = <A, E, R>(
discovery: Effect.Effect<ReadonlyArray<A>, E, R>,
) =>
discovery.pipe(
Effect.timeoutOption(EDITOR_DISCOVERY_TIMEOUT),
Effect.map(Option.getOrElse(() => [])),
);
function unexpectedCompatibilityError(error: never): never {
throw new Error(`Unhandled compatibility error: ${String(error)}`);
@@ -1087,7 +1096,9 @@ const makeWsRpcLayer = (
keybindings: keybindingsConfig.keybindings,
issues: keybindingsConfig.issues,
providers,
availableEditors: yield* externalLauncher.resolveAvailableEditors(),
availableEditors: yield* resolveAvailableEditorsForConfig(
externalLauncher.resolveAvailableEditors(),
),
observability: {
logsDirectoryPath: config.logsDir,
localTracingEnabled: true,