@@ -47,8 +47,11 @@ async function fetchServerFunction(
4747 } )
4848 : createRequest ( base , id , instance , {
4949 ...options ,
50- body : serializeToJSONStream ( args ) ,
51- headers : { ...options . headers , "Content-Type" : "application/json" } ,
50+ // TODO(Alexis): move to serializeToJSONStream
51+ body : await serializeToJSONString ( args ) ,
52+ // duplex: 'half',
53+ // body: serializeToJSONStream(args),
54+ headers : { ...options . headers , "Content-Type" : "text/plain" } ,
5255 } ) ) ;
5356
5457 if (
@@ -70,14 +73,16 @@ async function fetchServerFunction(
7073
7174 const contentType = response . headers . get ( "Content-Type" ) ;
7275 let result ;
73- if ( contentType && contentType . startsWith ( "text/plain" ) ) {
76+ if ( contentType ? .startsWith ( "text/plain" ) ) {
7477 result = await response . text ( ) ;
75- } else if ( contentType && contentType . startsWith ( "application/json" ) ) {
78+ } else if ( contentType ? .startsWith ( "application/json" ) ) {
7679 result = await response . json ( ) ;
77- } else if ( import . meta. env . SEROVAL_MODE === "js" ) {
78- result = await deserializeJSStream ( instance , response ) ;
79- } else {
80- result = await deserializeJSONStream ( response ) ;
80+ } else if ( response . headers . get ( 'x-serialized' ) ) {
81+ if ( import . meta. env . SEROVAL_MODE === "js" ) {
82+ result = await deserializeJSStream ( instance , response ) ;
83+ } else {
84+ result = await deserializeJSONStream ( response ) ;
85+ }
8186 }
8287 if ( response . headers . has ( "X-Error" ) ) {
8388 throw result ;
0 commit comments