feat: support using fetchEventSource for subscriptions

Open
#6,950 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
typescript
Domain
api

Research direction

Start by locating tRPC's subscription entry point and its current EventSource usage. Compare that flow with fetchEventSource, focusing on support for request headers and cross-origin cookies. Done means subscriptions can use those authentication mechanisms without exposing tokens in query parameters or requiring a separate subscription token process.

Written by the indexing model from the issue text.

Description

✅ accepted-PRs-welcome
Describe the feature you'd like to request

EventSource is lacking a ton of functionality that makes auth a giant PITA

  • headers are not supported
  • cross origin cookies are not supported.
Describe the solution you'd like to see

fetchEventSource fixes these shortcomings of EventSource.

Would be awesome to be able to utilize this out of the box in tRPC.

Describe alternate solutions

We use tRPC with header auth, but now to use subscriptions we have to either expose our tokens via a get param or implement a subscription specific token process.

Additional information

No response

👨‍👧‍👦 Contributing
  • 🙋‍♂️ Yes, I'd be down to file a PR implementing this feature!
Dominant language
TypeScript
Stars
40.6k
Forks
1.7k
Avg merge
1d 22h
Merged PRs (30d)
22

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from trpc/trpc

All issues in trpc/trpc

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.