@@ -707,30 +707,48 @@ describeDriverMatrix("Actor Conn", (driverTestConfig) => {
707707 await connection . dispose ( ) ;
708708 } ) ;
709709
710- test ( "should reject request exceeding maxIncomingMessageSize" , async ( c ) => {
710+ test ( "should reject request exceeding maxIncomingMessageSize via server " , async ( c ) => {
711711 const { client } = await setupDriverTest ( c , driverTestConfig ) ;
712712
713713 const handle = client . largePayloadConnActor . getOrCreate ( [
714714 "test-large-request-exceed" ,
715715 ] ) ;
716716 const connection = handle . connect ( ) ;
717717
718- // Create a payload that exceeds the default 64KB limit
719- // Each item is roughly 60 bytes, so 1500 items ≈ 90KB
718+ // Create a payload that exceeds the default 64KB limit.
719+ // Each item is roughly 60 bytes, so 1500 items ~ 90KB.
720+ // The server enforces the limit and closes the entire
721+ // WebSocket with reason "message.incoming_too_long".
720722 const items : string [ ] = [ ] ;
721723 for ( let i = 0 ; i < 1500 ; i ++ ) {
722724 items . push (
723725 `Item ${ i } with some additional text to increase size` ,
724726 ) ;
725727 }
726728
727- await expect (
728- connection . processLargeRequest ( { items } ) ,
729- ) . rejects . toMatchObject ( {
729+ // Send a normal action concurrently with the oversized
730+ // one to verify the server closes the whole connection,
731+ // not just the offending action.
732+ const [ oversizedResult , collateralResult ] =
733+ await Promise . allSettled ( [
734+ connection . processLargeRequest ( { items } ) ,
735+ connection . processLargeRequest ( {
736+ items : [ "small" ] ,
737+ } ) ,
738+ ] ) ;
739+
740+ expect ( oversizedResult . status ) . toBe ( "rejected" ) ;
741+ expect (
742+ ( oversizedResult as PromiseRejectedResult ) . reason ,
743+ ) . toMatchObject ( {
730744 group : "message" ,
731745 code : "incoming_too_long" ,
732746 } ) ;
733747
748+ // The normal action also fails because the server
749+ // closed the connection.
750+ expect ( collateralResult . status ) . toBe ( "rejected" ) ;
751+
734752 // Clean up
735753 await connection . dispose ( ) ;
736754 } ) ;
0 commit comments