Skip to content

Closing the stream manually聽#5

Closed

Description

@katywings

The README mentions that you obviously have to close the stream manually, if you use the keepalive config. Thing is, the API doesn't seem to provide a way to actually do that 馃槄 and the controller property is protected 馃檲.

My workaround for now:

export type SSE = typeof ServerSentEventGenerator.prototype;
export const closeStream = (stream: SSE) => {
  try {
    ((stream as any).controller as ReadableStreamController<any>).close();
  }
  catch(err) {}
}

(The try/catch exists, because there is no way to check if the stream already is closed and closing it multiple times results in an error. Yet onAbort has the tendency to be called multiple times.)

Activity

  1. added a commit that references this issue on Dec 3, 2025
    5837082
  2. eduwass commented on Dec 3, 2025

    @eduwass
    Collaborator

    Hi @katywings thanks for reporting this 馃檹

    Hopefully #11 should now resolve it.

    Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions