@@ -220,7 +220,9 @@ test('Limit can be disabled by setting maxPayloadSize to 0', async (t) => {
220220 t . after ( ( ) => server . close ( ) )
221221 await once ( server , 'listening' )
222222
223- const dataSize = 100 * 1024 * 1024 // 100 MB
223+ // Keep this comfortably above the smaller limits used elsewhere in this file,
224+ // while avoiding the 100 MB transfer that can be slow on CI.
225+ const dataSize = 2 * 1024 * 1024 // 2 MB
224226
225227 server . on ( 'connection' , ( ws ) => {
226228 ws . send ( Buffer . alloc ( dataSize , 0x41 ) , { binary : true } )
@@ -236,19 +238,16 @@ test('Limit can be disabled by setting maxPayloadSize to 0', async (t) => {
236238 t . after ( ( ) => agent . close ( ) )
237239
238240 const client = new WebSocket ( `ws://127.0.0.1:${ server . address ( ) . port } ` , { dispatcher : agent } )
241+ const timeout = Symbol ( 'timeout' )
239242
240- // Use Promise.race with timeout since large message takes time
241- const messagePromise = once ( client , 'message' )
242- const timeoutPromise = sleep ( 10000 )
243+ const result = await Promise . race ( [
244+ once ( client , 'message' ) ,
245+ sleep ( 10000 , timeout )
246+ ] )
243247
244- const result = await Promise . race ( [ messagePromise , timeoutPromise ] )
245-
246- if ( result ) {
247- t . assert . strictEqual ( result [ 0 ] . data . size , dataSize , 'Large message should be received when limit is disabled' )
248- client . close ( )
249- } else {
250- t . fail ( 'Test timed out waiting for large message' )
251- }
248+ t . assert . notStrictEqual ( result , timeout , 'Test timed out waiting for large message' )
249+ t . assert . strictEqual ( result [ 0 ] . data . size , dataSize , 'Large message should be received when limit is disabled' )
250+ client . close ( )
252251} )
253252
254253test ( 'Fragmented compressed payload over total limit is rejected' , async ( t ) => {
0 commit comments