Fix CI regressions after branch sync

Co-authored-by: codex <[email protected]>
This commit is contained in:
Julius Marmingeandcodex committed 2026-05-20 13:48:49 +02:00
1 parent 6b48288f77
commit 3ee6fbba2c
9 files changed
+181 -26

No files matched your search

@@ -645,8 +645,8 @@ describe("WsTransport", () => {
});
it("does not retry stream subscriptions after application-level failures", async () => {
const transport = createTransport("ws://localhost:3020");
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => undefined);
const warnSpy = vi.fn();
const transport = createTransport("ws://localhost:3020", undefined, { logWarning: warnSpy });
let attempts = 0;
const unsubscribe = transport.subscribe(
@@ -684,8 +684,8 @@ describe("WsTransport", () => {
});
it("keeps retrying stream subscriptions after transport failures", async () => {
const transport = createTransport("ws://localhost:3020");
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => undefined);
const warnSpy = vi.fn();
const transport = createTransport("ws://localhost:3020", undefined, { logWarning: warnSpy });
let attempts = 0;
const unsubscribe = transport.subscribe(
@@ -717,8 +717,8 @@ describe("WsTransport", () => {
});
it("logs a transport disconnect once even when multiple subscriptions fail together", async () => {
const transport = createTransport("ws://localhost:3020");
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => undefined);
const warnSpy = vi.fn();
const transport = createTransport("ws://localhost:3020", undefined, { logWarning: warnSpy });
const unsubscribeA = transport.subscribe(
() => Stream.fail(new Error("SocketCloseError: 1006")),
+14 -8
View File
@@ -31,6 +31,7 @@ export interface WsTransportOptions {
url: WsRpcProtocolSocketUrlProvider,
lifecycleHandlers?: WsProtocolLifecycleHandlers,
) => Layer.Layer<RpcClient.Protocol, never, never>;
readonly logWarning?: (message: string, metadata: { readonly error: string }) => void;
/**
* Invoked at the start of {@link WsTransport.reconnect} before the session is replaced.
*/
@@ -172,18 +173,14 @@ export class WsTransport {
const formattedError = formatErrorMessage(error);
if (!isTransportConnectionErrorMessage(formattedError)) {
Effect.runSync(
Effect.logWarning("WebSocket RPC subscription failed", { error: formattedError }),
);
this.logWarning("WebSocket RPC subscription failed", { error: formattedError });
return;
}
if (!this.hasReportedTransportDisconnect) {
Effect.runSync(
Effect.logWarning("WebSocket RPC subscription disconnected", {
error: formattedError,
}),
);
this.logWarning("WebSocket RPC subscription disconnected", {
error: formattedError,
});
}
this.hasReportedTransportDisconnect = true;
await sleep(retryDelayMs);
@@ -252,6 +249,15 @@ export class WsTransport {
};
}
private logWarning(message: string, metadata: { readonly error: string }) {
const logWarning = this.options?.logWarning;
if (logWarning) {
logWarning(message, metadata);
} else {
Effect.runSync(Effect.logWarning(message, metadata));
}
}
private runStreamOnSession<TValue>(
session: TransportSession,
connect: (client: WsRpcProtocolClient) => Stream.Stream<TValue, Error, never>,