The ELYSIA_RESPONSE symbol was removed in elysia@1.1.18, and a new strategy has to be used for detecting whether or not an error was returned by a handler.
Solution
Check if the response is an instance of the ElysiaCustomStatusResponse or has the same constructor name.
Reasoning
When the handler returns an error, mapResponse should not be called because there isn't a valid response to map. If an "error-like" object is encountered, the transform plugin will not transform it. This allows the thrown error to be visible as an HTTP error on the client. This is important for tanstack-query to know when deciding whether or not to retry.
If tanstack-query receives a 200 OK response with no data, then it will print a warning and not retry since the request was supposedly successful.
Issue
The
ELYSIA_RESPONSE
symbol was removed inelysia@1.1.18
, and a new strategy has to be used for detecting whether or not an error was returned by a handler.Solution
Check if the response is an instance of the
ElysiaCustomStatusResponse
or has the same constructor name.Reasoning
When the handler returns an error,
mapResponse
should not be called because there isn't a valid response to map. If an "error-like" object is encountered, the transform plugin will not transform it. This allows the thrown error to be visible as an HTTP error on the client. This is important fortanstack-query
to know when deciding whether or not to retry.If
tanstack-query
receives a 200 OK response with no data, then it will print a warning and not retry since the request was supposedly successful.