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

Refactor SSE callback to handle async operations #6

Merged
merged 1 commit into from
Dec 29, 2024

Conversation

alexanderkasten
Copy link
Owner

This pull request includes changes to enhance the Server-Sent Events (SSE) handler in src/server/sse-server.ts. The updates focus on improving the flexibility and functionality of the SSE callback and adding guidance for handling long-running operations.

Enhancements to SSE handler:

  • src/server/sse-server.ts: Updated the SSECallback type to allow the callback to return a promise that resolves to a cleanup function or a function that returns a promise.
  • src/server/sse-server.ts: Added a hint in the documentation to avoid awaiting long-running operations directly in the callback to prevent blocking the initial response.
  • src/server/sse-server.ts: Modified the start method in createSSEHandler to be asynchronous, allowing for better handling of asynchronous operations within the callback.
  • src/server/sse-server.ts: Updated the invocation of the callback in createSSEHandler to await its result, ensuring proper handling of asynchronous callbacks.

Copy link

vercel bot commented Dec 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
v0-next-sse-r1gecphzhel ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 29, 2024 1:38pm

@alexanderkasten alexanderkasten merged commit bbd605a into develop Dec 29, 2024
8 checks passed
@alexanderkasten alexanderkasten deleted the hotfix/cleanup_on_async_handler branch December 29, 2024 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant