@@ -84,75 +84,4 @@ describe("timeout", () => {
8484 success ( done , io , client ) ;
8585 } ) ;
8686 } ) ;
87-
88- it ( "should cleanup pending acks on broadcast timeout (memory leak fix)" , ( done ) => {
89- const io = new Server ( 0 ) ;
90- const client = createClient ( io , "/" ) ;
91-
92- // Client does not acknowledge the event (simulates timeout scenario)
93- client . on ( "test-event" , ( ) => {
94- // intentionally not calling the callback
95- } ) ;
96-
97- io . on ( "connection" , async ( socket ) => {
98- socket . join ( "test-room" ) ;
99-
100- // Get initial acks count (cast to any to access private property in test)
101- const initialAcksSize = ( socket as any ) . acks . size ;
102-
103- try {
104- await io . timeout ( 50 ) . to ( "test-room" ) . emitWithAck ( "test-event" , "data" ) ;
105- expect ( ) . fail ( "should have timed out" ) ;
106- } catch ( err ) {
107- expect ( err ) . to . be . an ( Error ) ;
108-
109- // After timeout, acks should be cleaned up (no memory leak)
110- // Wait a bit for cleanup to complete
111- setTimeout ( ( ) => {
112- expect ( ( socket as any ) . acks . size ) . to . be ( initialAcksSize ) ;
113- success ( done , io , client ) ;
114- } , 10 ) ;
115- }
116- } ) ;
117- } ) ;
118-
119- it ( "should cleanup pending acks on broadcast timeout with multiple clients" , ( done ) => {
120- const io = new Server ( 0 ) ;
121- const client1 = createClient ( io , "/" ) ;
122- const client2 = createClient ( io , "/" ) ;
123-
124- let connectedSockets : any [ ] = [ ] ;
125-
126- // Clients do not acknowledge
127- client1 . on ( "test-event" , ( ) => { } ) ;
128- client2 . on ( "test-event" , ( ) => { } ) ;
129-
130- io . on ( "connection" , ( socket ) => {
131- socket . join ( "test-room" ) ;
132- connectedSockets . push ( socket ) ;
133-
134- if ( connectedSockets . length === 2 ) {
135- runTest ( ) ;
136- }
137- } ) ;
138-
139- async function runTest ( ) {
140- const initialAcksSizes = connectedSockets . map ( ( s ) => s . acks . size ) ;
141-
142- try {
143- await io . timeout ( 50 ) . to ( "test-room" ) . emitWithAck ( "test-event" , "data" ) ;
144- expect ( ) . fail ( "should have timed out" ) ;
145- } catch ( err ) {
146- expect ( err ) . to . be . an ( Error ) ;
147-
148- setTimeout ( ( ) => {
149- // All sockets should have their acks cleaned up
150- connectedSockets . forEach ( ( socket , i ) => {
151- expect ( socket . acks . size ) . to . be ( initialAcksSizes [ i ] ) ;
152- } ) ;
153- success ( done , io , client1 , client2 ) ;
154- } , 10 ) ;
155- }
156- }
157- } ) ;
15887} ) ;
0 commit comments