File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -119,7 +119,25 @@ export class SSEServerTransport extends AbstractTransport {
119119 if ( ! isAuthenticated ) return
120120 }
121121
122- // Remove check for existing single _sseResponse
122+ // Check if a sessionId was provided in the request
123+ if ( sessionId ) {
124+ // If sessionId exists but is not in our connections map, it's invalid or inactive
125+ if ( ! this . _connections . has ( sessionId ) ) {
126+ logger . info ( `Invalid or inactive session ID in GET request: ${ sessionId } . Creating new connection.` ) ;
127+ // Continue execution to create a new connection below
128+ } else {
129+ // If the connection exists and is still active, we could either:
130+ // 1. Return an error (409 Conflict) as a client shouldn't create duplicate connections
131+ // 2. Close the old connection and create a new one
132+ // 3. Keep the old connection and return its details
133+
134+ // Option 2: Close old connection and create new one
135+ logger . info ( `Replacing existing connection for session ID: ${ sessionId } ` ) ;
136+ this . cleanupConnection ( sessionId ) ;
137+ // Continue execution to create a new connection below
138+ }
139+ }
140+
123141 // Generate a unique ID for this specific connection
124142 const connectionId = randomUUID ( ) ;
125143 this . setupSSEConnection ( res , connectionId ) ;
You can’t perform that action at this time.
0 commit comments