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

feat(server): websocket keep alive #5715

Merged
merged 9 commits into from
May 14, 2024
Merged

Conversation

buraktt
Copy link
Contributor

@buraktt buraktt commented May 12, 2024

Closes #2822

🎯 Changes

Heartbeat logic is implemented to keep connection alive.

βœ… Checklist

  • βœ… I have followed the steps listed in the Contributing guide.
  • βœ… If necessary, I have added documentation related to the changes made.
  • βœ… I have added or updated the tests related to the changes made.

@buraktt buraktt requested a review from a team as a code owner May 12, 2024 07:42
Copy link

vercel bot commented May 12, 2024

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Comments Updated (UTC)
www βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback May 14, 2024 8:24am

Copy link

vercel bot commented May 12, 2024

@buraktt is attempting to deploy a commit to the trpc Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Member

@KATT KATT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

Please use fake timers so the tests don't take over 3 seconds to run πŸ™

packages/tests/server/websockets.test.ts Outdated Show resolved Hide resolved
packages/server/src/adapters/ws.ts Outdated Show resolved Hide resolved
@buraktt
Copy link
Contributor Author

buraktt commented May 12, 2024

Thanks for this!

Please use fake timers so the tests don't take over 3 seconds to run πŸ™

Thanks for the quick review. Changes implemented πŸ‘

Copy link
Member

@KATT KATT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

FYI we'll have support for SSE soon too which will be nicer to use than WSS. you can peek in #5713

Copy link
Member

@KATT KATT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually - one more thing - please add docs too! πŸ™ Sorry I missed that was missing

@buraktt
Copy link
Contributor Author

buraktt commented May 13, 2024

@KATT docs updated.
SSE looks promising πŸš€

@KATT KATT enabled auto-merge (squash) May 13, 2024 21:40
@KATT KATT disabled auto-merge May 13, 2024 21:40
@KATT KATT changed the title Feat/websocket keep alive feat(server): websocket keep alive May 13, 2024
@KATT KATT enabled auto-merge (squash) May 13, 2024 21:41
@BeBoRE
Copy link

BeBoRE commented May 14, 2024

Just for curiosity, when is this useful? Heartbeat is built into the WebSocket standard already.

@buraktt
Copy link
Contributor Author

buraktt commented May 14, 2024

@BeBoRE this is useful when you need to keep connection open by utilizing ping/pong control messages from ws package. (or drop them in a reasonable time to release the used resources)

@BeBoRE
Copy link

BeBoRE commented May 14, 2024

Ohh, so heartbeat isn't done automatically? I thought the ws package would handle this automatically. My bad. Nice addition!

@buraktt buraktt deleted the feat/websocket-keep-alive branch May 14, 2024 15:11
Copy link

This pull request has been locked because we are very unlikely to see comments on closed issues. If you think, this PR is still necessary, create a new one with the same branch. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: Subscriptions heartbeat option
3 participants