{"record":{"id":"b328273d6d1fb0e1","repo":"hcengineering/platform","slug":"no-connection-available","errorCode":null,"errorMessage":"No connection available","messagePattern":"No connection available","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"foundations/net/packages/client/src/client.ts","lineNumber":347,"sourceCode":"      const existing = this.references.get(request.uuid)\n      if (existing !== undefined) {\n        return existing.ref\n      }\n    }\n    const [uuid, endpoint] = await this.retryGetContainerRef(kind, request)\n    const ref: ContainerReference = new ContainerReferenceImpl(uuid, this)\n    this.references.set(uuid, { kind, ref, request, endpoint })\n    return ref\n  }\n\n  establishConnection (uuid: ContainerUuid, endpoint: ContainerEndpointRef): ContainerConnectionImpl {\n    // Check if connection is routed\n    const parsedRef = parseEndpointRef(endpoint)\n    if (parsedRef.uuid === undefined) {\n      throw new Error('Invalid endpoint reference')\n    }\n    if (parsedRef.kind === EndpointKind.noconnect) {\n      throw new Error('No connection available')\n    }\n    if (parsedRef.kind === EndpointKind.routed) {\n      const agentRef = agentDirectRef(parsedRef.host, parsedRef.port, parsedRef.agentId)\n      let agentConn = this.agentConnections.get(agentRef)\n      if (agentConn === undefined) {\n        agentConn = new RoutedNetworkAgentConnectionImpl<ClientUuid>(\n          this.tickMgr,\n          this.clientId,\n          parsedRef.host,\n          parsedRef.port\n        )\n        this.agentConnections.set(agentRef, agentConn)\n      }\n      let conn = this.containerConnections.get(uuid)\n      if (conn === undefined) {\n        conn = new ContainerConnectionImpl(uuid, agentConn.connect(parsedRef.uuid))\n      } else {\n        conn.setConnection(agentConn.connect(parsedRef.uuid))","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/foundations/net/packages/client/src/client.ts#L329-L365","documentation":"After parsing, establishConnection inspects the endpoint kind. If it is EndpointKind.noconnect, the container explicitly published that no connection is currently possible (e.g. it is stopping, stateless, or not accepting connections), so the client refuses to establish and throws 'No connection available'.","triggerScenarios":"Connecting to a container whose latest endpoint ref is of kind noconnect — containers that are terminating, not yet ready, or intentionally non-connectable.","commonSituations":"Connect attempts racing with container shutdown; containers whose first published ref is noconnect before they become ready; retry loops hammering a stopping container.","solutions":["Wait for a connectable endpoint ref (non-noconnect) before connecting, e.g. via ref update events","Retry with backoff if the container is expected to become ready","Check container state first; skip connecting to stopping containers","Use the routed/agent path if the container publishes one instead of failing fast"],"exampleFix":"// before\nconst conn = client.conn(uuid)\n// after\nasync function connectWhenReady(uuid: ContainerUuid) {\n  for (;;) {\n    try { return client.conn(uuid) } catch { await sleep(500) }\n  }\n}","handlingStrategy":"retry","validationCode":"const parsed = parseEndpointRef(endpoint)\nif (parsed.kind === EndpointKind.noconnect) {\n  await waitForRefUpdate(uuid) // don't attempt connect yet\n}","typeGuard":"function isConnectable(endpoint: ContainerEndpointRef): boolean {\n  return parseEndpointRef(endpoint).kind !== EndpointKind.noconnect\n}","tryCatchPattern":"for (let attempt = 0; attempt < 5; attempt++) {\n  try { return client.conn(uuid) }\n  catch (e) {\n    if (e instanceof Error && e.message === 'No connection available') {\n      await sleep(500 * 2 ** attempt); continue\n    }\n    throw e\n  }\n}","preventionTips":["Subscribe to ref updates and connect only on connectable kind","Check container liveness before connecting","Use exponential backoff for transient noconnect","Stop retrying when container termination is confirmed"],"tags":["endpoint","connection","container-state","retry"],"backgroundTag":"invalid-endpoint-reference","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}