You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
server$ server call is not being serialized on the sever to match the network boundary which can result in runtime errors if passing un-serializable objects like Date/Map/Set
on the server the function in called directly
/*** currently in the context of the server render you can basically think this as const fn = () => new Date()*/const$$server_module0=fetch$.createHandler(asyncfunction$$serverHandler0(){returnnewDate();},"/_m/43dde1d673/getNow",undefined);fetch$.registerHandler("/_m/43dde1d673/getNow",$$server_module0);
and on the client its a fetch to the endpoint
/** * again you can think of this as const fn = () => fetch('/_m/0dbe216f23/clientDate')*/const$$server_module0=fetch$.createFetcher('/_m/7d3e2194d0/clientDate',void0),
another thing to note is when this is fixed server$ return type will not reflect what is really returned.. for simple values like number object and string it is correct.. but when returning something that is not serializable like Date Map or Set. the return types don't match what is being parsed on the wire. ex Date -> string, Map -> {}.
TRPC had this same issue trpc/trpc#3261 i prototypes fixing the return types for solid-start by copying what TRPC did but this only handles using JSON.parse & stringify. with bling supporting custom serializer & deserializer types should refelect this somehow
Something to also note this happens for parameter's as well if you have a function that expects a Date the server render will succeed and pass a date object and on client render it will get serialized to a string causing the server to crash.
constclientDate=server$(async(date: Date)=>{console.log('datePassedToServer','type',typeofdate,'value',date)// the server render will get a Date but when the client calls it will be a stringconsole.log('toLocaleDateString()',date.toLocaleDateString())})clientDate(newDate());// this causes the server to crash when the client calls it
Describe the bug
server$ server call is not being serialized on the sever to match the network boundary which can result in runtime errors if passing un-serializable objects like Date/Map/Set
on the server the function in called directly
and on the client its a fetch to the endpoint
This also effects solid-start solidjs/solid-start#792. Bling currently does try to parse client and server the same but only for Reponse objects
another thing to note is when this is fixed server$ return type will not reflect what is really returned.. for simple values like number object and string it is correct.. but when returning something that is not serializable like Date Map or Set. the return types don't match what is being parsed on the wire. ex Date -> string, Map -> {}.
TRPC had this same issue trpc/trpc#3261 i prototypes fixing the return types for solid-start by copying what TRPC did but this only handles using JSON.parse & stringify. with bling supporting custom serializer & deserializer types should refelect this somehow
Your Example Website or App
https://stackblitz.com/edit/github-uqyvwn?file=examples%2Fastro-solid%2Fpackage.json,examples%2Fastro-solid%2Fsrc%2Fapp%2Froot.tsx
Steps to Reproduce the Bug or Issue
/
Expected behavior
The return type should reflect the network boundary and serialize the response
Screenshots or Videos
No response
Platform
Additional context
No response
The text was updated successfully, but these errors were encountered: