MCPcopy Create free account
hub / github.com/cloudflare/computer / connect

Method connect

packages/computer/src/backends/test.ts:36–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34 }
35
36 async connect(): Promise<BackendHandle> {
37 const wsUrl = toWebSocketUrl(this.#url);
38 // Probe /health before constructing the RPC stub. capnweb's
39 // WebSocket session queues calls until the upgrade succeeds,
40 // so we'd otherwise discover a misconfigured URL only on the
41 // first RPC. The probe surfaces "harness forgot to start the
42 // container" up front.
43 await probeHealth(this.#url);
44 const client = createWorkspaceClient({ url: `${wsUrl}/ws` });
45 return {
46 rpc: client,
47 close: async () => {
48 await client.close();
49 },
50 };
51 }
52}
53
54function toWebSocketUrl(input: string): string {

Callers

nothing calls this directly

Calls 4

createWorkspaceClientFunction · 0.90
probeHealthFunction · 0.85
toWebSocketUrlFunction · 0.70
closeMethod · 0.65

Tested by

no test coverage detected