@@ -199,13 +199,25 @@ promise_test(async t => {
199199 const writer = wt . datagrams . writable . getWriter ( ) ;
200200 const reader = wt . datagrams . readable . getReader ( ) ;
201201
202- // Write and read max-size datagram.
203- await writer . write ( new Uint8Array ( wt . datagrams . maxDatagramSize + 1 ) ) ;
204- // This should resolve with no datagram sent, which is hard to test for.
205- // Wait for incoming datagrams to arrive, and if they do, fail.
206- const result = await Promise . race ( [ reader . read ( ) , wait ( 500 ) ] ) ;
207- assert_equals ( result , undefined ) ;
208- } , 'Fail to transfer max-size+1 datagram' ) ;
202+ let maxDatagramSize = wt . datagrams . maxDatagramSize ;
203+
204+ while ( true ) {
205+ // Write and read max-size datagram.
206+ await writer . write ( new Uint8Array ( maxDatagramSize + 1 ) ) ;
207+ // This should resolve with no datagram sent, which is hard to test for.
208+ // Wait for incoming datagrams to arrive, and if they do, fail.
209+ const result = await Promise . race ( [ reader . read ( ) , wait ( 500 ) ] ) ;
210+ if ( result === undefined ) {
211+ return ; // Success, no datagram received, exit the test early.
212+ }
213+
214+ // Maybe QUIC's PMTUD increased the max-size datagram in the meantime. If
215+ // so, try again.
216+ const currentMaxDatagramSize = wt . datagrams . maxDatagramSize ;
217+ assert_greater_than ( currentMaxDatagramSize , maxDatagramSize ) ;
218+ maxDatagramSize = currentMaxDatagramSize ;
219+ }
220+ } , 'Fail to transfer max-size+1 datagram, handle PMTUD increases' ) ;
209221
210222promise_test ( async t => {
211223 // Make a WebTransport connection, but session is not necessarily established.
0 commit comments