Conversation
…management - Add comprehensive SSE message formatting with multiline support - Implement streaming support for async generators and Node.js streams - Add connection lifecycle management with keepAlive and close handlers - Support message replay functionality with Last-Event-ID header - Include configurable heartbeat mechanism for connection health - Add route-level SSE configuration with fallback to regular handlers - Provide TypeScript definitions for full type safety - Include comprehensive test coverage for all features - Add working examples demonstrating plugin capabilities
- Align reply.sse.send() and reply.sse.stream() method signatures with agreed design - Update API documentation and examples to reflect final implementation - Ensure compatibility with Fastify's request/reply lifecycle patterns - Standardize method interfaces based on community discussion outcomes
- Remove trailing whitespace and add missing newlines for linting compliance - Update Windows test command to explicitly list test files instead of using glob patterns - Ensure all files meet Standard.js formatting requirements
The README was incorrectly showing reply.sse() which would cause runtime errors. Updated all examples to use the correct reply.sse.send() API that matches the actual implementation. This fixes critical documentation errors that would prevent users from successfully using the plugin.
Member
Author
climba03003
approved these changes
Aug 23, 2025
Member
climba03003
left a comment
There was a problem hiding this comment.
LGTM.
We should change to neostandard + eslint before release.
- Replace standard dependency with eslint and neostandard - Update lint scripts to use eslint instead of standard - Add eslint.config.js with neostandard configuration - Maintains same code style rules through neostandard preset
climba03003
approved these changes
Aug 23, 2025
Uzlopak
reviewed
Aug 25, 2025
Contributor
|
I will try to use this plugin for smee.io to check if I see issues in real use |
Co-authored-by: Aras Abbasi <aras.abbasi@googlemail.com> Signed-off-by: Matteo Collina <matteo.collina@gmail.com>
Member
Author
|
@Uzlopak if you lgtm it I'll ship a 0.0.1. |
Contributor
|
Lets go :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements a comprehensive Server-Sent Events (SSE) plugin for Fastify, directly implementing the API design agreed upon in fastify/fastify#6276. The implementation provides first-class SSE support with clean
reply.sse.send()andreply.sse.stream()methods as specified in the community discussion.Key Features Implemented
• Unified API Interface: Clean
reply.sse.*methods that integrate seamlessly with Fastify's request/reply cycle• Multiple Data Sources: Support for single messages, async generators, Node.js streams, and plain strings
• Session Management: Built-in connection state tracking with
isConnectedandkeepAlive()functionality• Message Replay: Automatic handling of client reconnections with
Last-Event-IDheader support• Heartbeat System: Configurable keep-alive mechanism to maintain connections
• Route-level Configuration: Routes can be marked with
{ sse: true }for automatic SSE handling• Graceful Fallback: Non-SSE requests to SSE routes receive regular JSON responses
API Examples
Basic Message Sending with
reply.sse.send()Streaming with
reply.sse.stream()Route Configuration
Testing Coverage
Comprehensive test suite covering:
reply.sse.send()andreply.sse.stream()with various data typesTypeScript Support
Complete TypeScript definitions provided:
reply.sse.*methods{ sse: true }Implementation Architecture
The plugin follows the API design from fastify/fastify#6276 by:
Accept: text/event-streamheaderreply.sse.send()andreply.sse.stream()methods to the reply objectThis implementation is production-ready and follows Fastify plugin conventions while delivering the exact API interface agreed upon in the GitHub issue discussion.