Skip to content

SubscriptionEnd

type SubscriptionEnd =
| {
accepted: boolean;
cause: "request-error";
error: RequestError;
kind: "rejected" | "terminated";
}
| {
accepted: boolean;
cause: "connection-closed";
error: unknown;
kind: "terminated";
}
| {
accepted: boolean;
cause: "cancelled";
error: unknown;
kind: "cancelled";
};

Defined in: relay-sdks/ts/src/subscription.ts:105

How a subscription ended. kind is the lifecycle name; cause is what happened on the wire or locally; accepted says whether SUBSCRIBE_OK had arrived; error is the REQUEST_ERROR, the connection’s failure (undefined after a clean shutdown), or the cancel reason.

{
accepted: boolean;
cause: "request-error";
error: RequestError;
kind: "rejected" | "terminated";
}
accepted: boolean;

Whether SUBSCRIBE_OK had arrived.

cause: "request-error";

The relay answered with REQUEST_ERROR, or the request timed out or its stream failed.

error: RequestError;

The REQUEST_ERROR, with its numeric code and reason.

kind: "rejected" | "terminated";

rejected before SUBSCRIBE_OK, terminated after it.


{
accepted: boolean;
cause: "connection-closed";
error: unknown;
kind: "terminated";
}
accepted: boolean;

Whether SUBSCRIBE_OK had arrived.

cause: "connection-closed";

The connection ended, cleanly or not.

error: unknown;

The connection’s failure, or undefined after a clean shutdown.

kind: "terminated";

Always terminated, including when the connection ended before any answer.


{
accepted: boolean;
cause: "cancelled";
error: unknown;
kind: "cancelled";
}
accepted: boolean;

Whether SUBSCRIBE_OK had arrived.

cause: "cancelled";

cancel() ran, called directly or by an events iterator that closed, aborted or overflowed.

error: unknown;

The cancel reason, or undefined when none was given.

kind: "cancelled";

The subscription was cancelled locally.