Skip to content
Source
Sign inSign up
pingdotgg/t3code

test(server): measure shell, second client, and reconnect transfer #9157

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/9157/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Showing 6 changed files with 89 additions and 1 deletion (loading 3).

x
0 of 6 viewed, 6 left
59 additions and 1 deletionapps/server/integration/NetworkTransferMeasurement.integration.tsModified
View file
@@ -5,8 +5,10 @@
import * as NodeSocket from "@effect/platform-node/NodeSocket";
import { WsRpcGroup } from "@t3tools/contracts";
import * as Effect from "effect/Effect";
+import * as Exit from "effect/Exit";
import * as Layer from "effect/Layer";
import * as Schema from "effect/Schema";
+import * as Scope from "effect/Scope";
import { RpcClient, RpcSerialization } from "effect/unstable/rpc";
import * as Socket from "effect/unstable/socket/Socket";
​
@@ -101,6 +103,8 @@
) => globalThis.WebSocket;
readonly totals: () => WebSocketTransferTotals;
readonly negotiatedExtensions: () => string;
+ /** Resolves once the upgrade completes, so totals taken after it exclude the upgrade response. */
+ readonly awaitOpen: Effect.Effect<void>;
​
interface NodeWebSocketWithTransport extends NodeSocket.NodeWS.WebSocket {
@@ -118,8 +122,15 @@
​
export function makeWebSocketTransferRecorder(): WebSocketTransferRecorder {
let socket: NodeWebSocketWithTransport | null = null;
+ // Held separately from the WebSocket so wire totals survive a close, which
+ // is when a reconnect measurement reads them.
+ let transport: NodeWebSocketWithTransport["_socket"] | null = null;
let decodedBytes = 0;