@@ -5,7 +5,7 @@ import { Client } from '../client/index.js';
55import { StreamableHTTPClientTransport } from '../client/streamableHttp.js' ;
66import { McpServer } from '../server/mcp.js' ;
77import { EventStore , StreamableHTTPServerTransport } from '../server/streamableHttp.js' ;
8- import { CallToolResult , CallToolResultSchema , JSONRPCMessage , LoggingMessageNotificationSchema } from '../types.js' ;
8+ import { CallToolResultSchema , JSONRPCMessage , LoggingMessageNotificationSchema } from '../types.js' ;
99import { z } from 'zod' ;
1010
1111/**
@@ -204,19 +204,18 @@ describe('Transport resumability', () => {
204204 it ( 'should resume long-running notifications with lastEventId' , async ( ) => {
205205 // Create unique client ID for this test
206206 const clientId = 'test-client-long-running' ;
207- const notifications : any [ ] = [ ] ;
208- let sessionId : string | undefined ;
207+ const notifications = [ ] ;
209208 let lastEventId : string | undefined ;
210209
211210 // Create first client
212- let client1 = new Client ( {
211+ const client1 = new Client ( {
213212 id : clientId ,
214213 name : 'test-client' ,
215214 version : '1.0.0'
216215 } ) ;
217216
218217 // Set up notification handler for first client
219- client1 . setNotificationHandler ( LoggingMessageNotificationSchema , ( notification : any ) => {
218+ client1 . setNotificationHandler ( LoggingMessageNotificationSchema , ( notification ) => {
220219 if ( notification . method === 'notifications/message' ) {
221220 notifications . push ( notification . params ) ;
222221 }
@@ -225,14 +224,14 @@ describe('Transport resumability', () => {
225224 // Connect first client
226225 const transport1 = new StreamableHTTPClientTransport ( baseUrl ) ;
227226 await client1 . connect ( transport1 ) ;
228- sessionId = transport1 . sessionId ;
227+ const sessionId = transport1 . sessionId ;
229228 expect ( sessionId ) . toBeDefined ( ) ;
230229
231230 // Start a long-running notification stream with tracking of lastEventId
232231 const onLastEventIdUpdate = jest . fn ( ( eventId : string ) => {
233232 lastEventId = eventId ;
234233 } ) ;
235-
234+ expect ( lastEventId ) . toBeUndefined ( ) ;
236235 // Start the notification tool with event tracking using request
237236 const toolPromise = client1 . request ( {
238237 method : 'tools/call' ,
@@ -284,7 +283,7 @@ describe('Transport resumability', () => {
284283 } ) ;
285284
286285 // Set up notification handler for second client
287- client2 . setNotificationHandler ( LoggingMessageNotificationSchema , ( notification : any ) => {
286+ client2 . setNotificationHandler ( LoggingMessageNotificationSchema , ( notification ) => {
288287 if ( notification . method === 'notifications/message' ) {
289288 notifications . push ( notification . params ) ;
290289 }
@@ -298,12 +297,12 @@ describe('Transport resumability', () => {
298297
299298 // Resume the notification stream using lastEventId
300299 // This is the key part - we're resuming the same long-running tool using lastEventId
301- const resumedToolPromise = client2 . request ( {
300+ await client2 . request ( {
302301 method : 'tools/call' ,
303302 params : {
304303 name : 'run-notifications' ,
305304 arguments : {
306- count : 5 ,
305+ count : 1 ,
307306 interval : 50
308307 }
309308 }
@@ -312,9 +311,6 @@ describe('Transport resumability', () => {
312311 onLastEventIdUpdate
313312 } ) ;
314313
315- // Wait for remaining notifications
316- await new Promise ( resolve => setTimeout ( resolve , 200 ) ) ;
317-
318314 // Verify we eventually received at leaset a few motifications
319315 expect ( notifications . length ) . toBeGreaterThan ( 2 ) ;
320316
0 commit comments