Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions apps/server/src/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -3728,6 +3729,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, []);
}),
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Timeout test missing yieldNow

Medium Severity

The new editor-discovery timeout test forks resolveAvailableEditorsForConfig over Effect.never, then calls TestClock.adjust without first yielding so the child fiber can register its timer. That diverges from the repo’s forkChild + TestClock.adjust pattern and can leave Fiber.join waiting forever, hanging CI.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4bd5bcf. Configure here.


it.effect(
"rejects websocket rpc handshake when a session token is only provided via query string",
() =>
Expand Down
13 changes: 12 additions & 1 deletion apps/server/src/ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,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)}`);
Expand Down Expand Up @@ -1080,7 +1089,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,
Expand Down
Loading