File tree 3 files changed +14
-3
lines changed
3 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -136,8 +136,6 @@ export class SSEServerTransport implements Transport {
136
136
137
137
/**
138
138
* Returns the session ID for this transport.
139
- *
140
- * This can be used to route incoming POST requests.
141
139
*/
142
140
get sessionId ( ) : string {
143
141
return this . _sessionId ;
Original file line number Diff line number Diff line change @@ -74,6 +74,11 @@ export type RequestHandlerExtra = {
74
74
* An abort signal used to communicate if the request was cancelled from the sender's side.
75
75
*/
76
76
signal : AbortSignal ;
77
+
78
+ /**
79
+ * The session ID from the transport, if available.
80
+ */
81
+ sessionId ?: string ;
77
82
} ;
78
83
79
84
/**
@@ -239,9 +244,15 @@ export abstract class Protocol<
239
244
const abortController = new AbortController ( ) ;
240
245
this . _requestHandlerAbortControllers . set ( request . id , abortController ) ;
241
246
247
+ // Create extra object with both abort signal and sessionId from transport
248
+ const extra : RequestHandlerExtra = {
249
+ signal : abortController . signal ,
250
+ sessionId : this . _transport ?. sessionId ,
251
+ } ;
252
+
242
253
// Starting with Promise.resolve() puts any synchronous errors into the monad as well.
243
254
Promise . resolve ( )
244
- . then ( ( ) => handler ( request , { signal : abortController . signal } ) )
255
+ . then ( ( ) => handler ( request , extra ) )
245
256
. then (
246
257
( result ) => {
247
258
if ( abortController . signal . aborted ) {
Original file line number Diff line number Diff line change @@ -41,4 +41,6 @@ export interface Transport {
41
41
* Callback for when a message (request or response) is received over the connection.
42
42
*/
43
43
onmessage ?: ( message : JSONRPCMessage ) => void ;
44
+
45
+ sessionId ?: string ;
44
46
}
You can’t perform that action at this time.
0 commit comments