phero
phero copied to clipboard
fix undefined response resulting in JSON syntax error
The following example RPC
export async function test(): Promise<undefined> {
return undefined
}
will always trigger the following error on the client when called:
Uncaught (in promise) SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data
The issue is the incomplete handling of 'undefined' responses. For the DevServer we convert undefined responses to 204 No Content responses, while the client doesn't know how to deal with these. The export servers don't know how to deal with 'undefined' responses either, and try to serialize them anyway.
Fix this by making the client understand 204 No Content responses, and by making the export servers also be able to generate 204 No Content responses.