Skip to content
TypeWire

@tahanabavi/typesocket

v2.2.0

Contract-driven, type-safe Socket.IO client — one Zod contract validated in both directions, with acks, middleware, queueing and a devtools instrumentation seam.

Errors

Every error extends SocketError and carries a stable code plus the eventId it belongs to.

ClassCodeRaised when
SocketValidationErrorERR_SOCKET_VALIDATIONA frame fails its schema. phase is "request", "ack" or "payload"; issues holds the Zod issues.
SocketAckTimeoutErrorERR_SOCKET_ACK_TIMEOUTNo acknowledgement arrived in time.
SocketNotConnectedErrorERR_SOCKET_NOT_CONNECTEDAn emit was attempted with no live connection.
SocketWaitTimeoutErrorERR_SOCKET_WAIT_TIMEOUT.wait() expired.
SocketOverrideErrorERR_SOCKET_OVERRIDEAn instrumentation override forced a failure.
ts
import { SocketValidationError } from "@tahanabavi/typesocket";

try {
await client.modules.chat.sendMessage({ roomId: "r1", text: "" });
} catch (error) {
if (error instanceof SocketValidationError) console.error(error.issues);
}