fix(compiler): stop error {} from swallowing response {} bugs in api blocks

Client codegen chained .then().catch(), so a .catch() after .then()
caught exceptions thrown by the response body too. Switched to the
two-argument then(onFulfilled, onRejected) form, whose rejection
handler cannot see errors from the fulfilment handler.

SSR codegen wrapped both the transport call and the response-body eval
in the same try; only __wrnexusCallApi is now inside the try, and
__wrnexusEvalData runs after it, outside.

Also verifies (and locks in with a regression test) that GET query
numbers already coerce correctly through defineEndpoint + checkField,
and documents that in the typed-api-block spec.
This commit is contained in:
2026-08-19 21:11:26 +05:30
parent b5029889a5
commit 3ae5d7cf97
8 changed files with 239 additions and 9 deletions
+3 -2
View File
@@ -1056,12 +1056,13 @@ async function __wrnexusResolveApiBinding(
ctx: __WrnexusContext,
): Promise<unknown> {
if (binding.errorBody) {
let data: unknown;
try {
const data = await __wrnexusCallApi(binding.path, binding.method, ctx);
return __wrnexusEvalData(data, binding.body, binding.helpers, ctx);
data = await __wrnexusCallApi(binding.path, binding.method, ctx);
} catch (err) {
return __wrnexusEvalError(err, binding.errorBody, binding.helpers, ctx);
}
return __wrnexusEvalData(data, binding.body, binding.helpers, ctx);
}
const data = await __wrnexusCallApi(binding.path, binding.method, ctx);
return __wrnexusEvalData(data, binding.body, binding.helpers, ctx);