Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support AbortController in a client #381

Open
nounder opened this issue May 21, 2023 · 1 comment
Open

Support AbortController in a client #381

nounder opened this issue May 21, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@nounder
Copy link
Contributor

nounder commented May 21, 2023

Currently it is not possible pass AbortController signal to a client. It would be immensely useful to support that in streaming HTTP handlers.

Example:

http.serve(async (req: Request) => {
  const redis = await connect({ hostname: "127.0.0.1", signal: req.signal })
  const events = new http.ServerSentEventStreamTarget({ keepAlive: true })

  while (true) {
    const [stream] = await redis.xread([
      { key: `worker:${id}:events`, xid: "*" },
    ])

    // Send events from a stream.
  }

  return events.asResponse()
})
@nounder
Copy link
Contributor Author

nounder commented May 21, 2023

Current solution:

const redis = await connect({
  hostname: "127.0.0.1",
})

req.signal.addEventListener("abort", () => {
  redis.close()
})

@nounder nounder changed the title Support AbortController Support AbortController in a client May 21, 2023
@uki00a uki00a added the enhancement New feature or request label Jul 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants