# SubscriptionEnd

URL: https://www.caprid.com/docs/reference/typescript/caprid/relay/index/type-aliases/subscriptionend/

```ts
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](https://github.com/caprids/relay-sdks/blob/main/ts/src/subscription.ts#L105)

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.

## Union Members

### Type Literal

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

#### accepted

```ts
accepted: boolean;
```

Whether SUBSCRIBE_OK had arrived.

#### cause

```ts
cause: "request-error";
```

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

#### error

```ts
error: RequestError;
```

The REQUEST_ERROR, with its numeric code and reason.

#### kind

```ts
kind: "rejected" | "terminated";
```

`rejected` before SUBSCRIBE_OK, `terminated` after it.

***

### Type Literal

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

#### accepted

```ts
accepted: boolean;
```

Whether SUBSCRIBE_OK had arrived.

#### cause

```ts
cause: "connection-closed";
```

The connection ended, cleanly or not.

#### error

```ts
error: unknown;
```

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

#### kind

```ts
kind: "terminated";
```

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

***

### Type Literal

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

#### accepted

```ts
accepted: boolean;
```

Whether SUBSCRIBE_OK had arrived.

#### cause

```ts
cause: "cancelled";
```

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

#### error

```ts
error: unknown;
```

The cancel reason, or `undefined` when none was given.

#### kind

```ts
kind: "cancelled";
```

The subscription was cancelled locally.
