refactor(gateway): share node invoke error handling

This commit is contained in:
Peter Steinberger
2026-02-16 01:25:06 +00:00
parent b1dca644bc
commit 73a97ee255
4 changed files with 36 additions and 34 deletions

View File

@@ -28,6 +28,7 @@ import {
import { handleNodeInvokeResult } from "./nodes.handlers.invoke-result.js";
import {
respondInvalidParams,
respondUnavailableOnNodeInvokeError,
respondUnavailableOnThrow,
safeParseJson,
uniqueSortedStrings,
@@ -433,14 +434,7 @@ export const nodeHandlers: GatewayRequestHandlers = {
timeoutMs: p.timeoutMs,
idempotencyKey: p.idempotencyKey,
});
if (!res.ok) {
respond(
false,
undefined,
errorShape(ErrorCodes.UNAVAILABLE, res.error?.message ?? "node invoke failed", {
details: { nodeError: res.error ?? null },
}),
);
if (!respondUnavailableOnNodeInvokeError(respond, res)) {
return;
}
const payload = res.payloadJSON ? safeParseJson(res.payloadJSON) : res.payload;