@@ -5,7 +5,7 @@ import { Client } from '../client/index.js';
5
5
import { StreamableHTTPClientTransport } from '../client/streamableHttp.js' ;
6
6
import { McpServer } from '../server/mcp.js' ;
7
7
import { EventStore , StreamableHTTPServerTransport } from '../server/streamableHttp.js' ;
8
- import { CallToolResult , CallToolResultSchema , JSONRPCMessage , LoggingMessageNotificationSchema } from '../types.js' ;
8
+ import { CallToolResultSchema , JSONRPCMessage , LoggingMessageNotificationSchema } from '../types.js' ;
9
9
import { z } from 'zod' ;
10
10
11
11
/**
@@ -204,19 +204,18 @@ describe('Transport resumability', () => {
204
204
it ( 'should resume long-running notifications with lastEventId' , async ( ) => {
205
205
// Create unique client ID for this test
206
206
const clientId = 'test-client-long-running' ;
207
- const notifications : any [ ] = [ ] ;
208
- let sessionId : string | undefined ;
207
+ const notifications = [ ] ;
209
208
let lastEventId : string | undefined ;
210
209
211
210
// Create first client
212
- let client1 = new Client ( {
211
+ const client1 = new Client ( {
213
212
id : clientId ,
214
213
name : 'test-client' ,
215
214
version : '1.0.0'
216
215
} ) ;
217
216
218
217
// Set up notification handler for first client
219
- client1 . setNotificationHandler ( LoggingMessageNotificationSchema , ( notification : any ) => {
218
+ client1 . setNotificationHandler ( LoggingMessageNotificationSchema , ( notification ) => {
220
219
if ( notification . method === 'notifications/message' ) {
221
220
notifications . push ( notification . params ) ;
222
221
}
@@ -225,14 +224,14 @@ describe('Transport resumability', () => {
225
224
// Connect first client
226
225
const transport1 = new StreamableHTTPClientTransport ( baseUrl ) ;
227
226
await client1 . connect ( transport1 ) ;
228
- sessionId = transport1 . sessionId ;
227
+ const sessionId = transport1 . sessionId ;
229
228
expect ( sessionId ) . toBeDefined ( ) ;
230
229
231
230
// Start a long-running notification stream with tracking of lastEventId
232
231
const onLastEventIdUpdate = jest . fn ( ( eventId : string ) => {
233
232
lastEventId = eventId ;
234
233
} ) ;
235
-
234
+ expect ( lastEventId ) . toBeUndefined ( ) ;
236
235
// Start the notification tool with event tracking using request
237
236
const toolPromise = client1 . request ( {
238
237
method : 'tools/call' ,
@@ -284,7 +283,7 @@ describe('Transport resumability', () => {
284
283
} ) ;
285
284
286
285
// Set up notification handler for second client
287
- client2 . setNotificationHandler ( LoggingMessageNotificationSchema , ( notification : any ) => {
286
+ client2 . setNotificationHandler ( LoggingMessageNotificationSchema , ( notification ) => {
288
287
if ( notification . method === 'notifications/message' ) {
289
288
notifications . push ( notification . params ) ;
290
289
}
@@ -298,12 +297,12 @@ describe('Transport resumability', () => {
298
297
299
298
// Resume the notification stream using lastEventId
300
299
// This is the key part - we're resuming the same long-running tool using lastEventId
301
- const resumedToolPromise = client2 . request ( {
300
+ await client2 . request ( {
302
301
method : 'tools/call' ,
303
302
params : {
304
303
name : 'run-notifications' ,
305
304
arguments : {
306
- count : 5 ,
305
+ count : 1 ,
307
306
interval : 50
308
307
}
309
308
}
@@ -312,9 +311,6 @@ describe('Transport resumability', () => {
312
311
onLastEventIdUpdate
313
312
} ) ;
314
313
315
- // Wait for remaining notifications
316
- await new Promise ( resolve => setTimeout ( resolve , 200 ) ) ;
317
-
318
314
// Verify we eventually received at leaset a few motifications
319
315
expect ( notifications . length ) . toBeGreaterThan ( 2 ) ;
320
316
0 commit comments