@@ -1394,7 +1394,11 @@ function formEnhance<T extends AnyZodObject, M>(
13941394 setTimeout ( ( ) => validationResponse ( { result } ) , 0 ) ;
13951395 } else if ( options . dataType === 'json' ) {
13961396 const postData = get ( data ) ;
1397- submit . data . set ( '__superform_json' , stringify ( postData ) ) ;
1397+ const chunks = chunkSubstr ( stringify ( postData ) , 500000 ) ;
1398+
1399+ for ( const chunk of chunks ) {
1400+ submit . data . append ( '__superform_json' , chunk ) ;
1401+ }
13981402
13991403 // Clear post data to reduce transfer size,
14001404 // since $form should be serialized and sent as json.
@@ -1408,6 +1412,18 @@ function formEnhance<T extends AnyZodObject, M>(
14081412 }
14091413 }
14101414
1415+ // Thanks to https://stackoverflow.com/a/29202760/70894
1416+ function chunkSubstr ( str : string , size : number ) {
1417+ const numChunks = Math . ceil ( str . length / size ) ;
1418+ const chunks = new Array ( numChunks ) ;
1419+
1420+ for ( let i = 0 , o = 0 ; i < numChunks ; ++ i , o += size ) {
1421+ chunks [ i ] = str . substring ( o , o + size ) ;
1422+ }
1423+
1424+ return chunks ;
1425+ }
1426+
14111427 async function validationResponse ( event : ValidationResponse ) {
14121428 const result = event . result ;
14131429
0 commit comments