Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions src/lib/graphUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,10 @@ async function loadBackendLimits(baseUrl: string): Promise<BackendLimits> {
function annotateDirtyNodesWithError(
nodes: Node<CalculationNodeData>[],
message: string
) {
nodes.forEach((node) => {
if (node.data?.dirty) {
node.data.error = true;
node.data.extendedError = message;
}
): Node<CalculationNodeData>[] {
return nodes.map((node) => {
if (!node.data?.dirty) return node;
return { ...node, data: { ...node.data, error: true, extendedError: message } };
});
}

Expand Down Expand Up @@ -178,9 +176,8 @@ export async function recalculateGraph(
const limitMessage = `Request is ${formatBytes(
payloadBytes
)}, over the server limit (${formatBytes(maxPayloadBytes)}).`;
annotateDirtyNodesWithError(nodes, limitMessage);
return {
nodes,
nodes: annotateDirtyNodesWithError(nodes, limitMessage),
version,
errors: [{ nodeId: PAYLOAD_LIMIT_NODE_ID, error: limitMessage }],
};
Expand Down Expand Up @@ -223,11 +220,8 @@ export async function recalculateGraph(
? "Backend not running. Start it with: python routes.py"
: "Cannot connect to calculation service. Please try again later.";

// Mark all dirty nodes with error
annotateDirtyNodesWithError(nodes, message);

return {
nodes: nodes,
nodes: annotateDirtyNodesWithError(nodes, message),
version: version,
errors: [], // No system error - the node errors are enough
};
Expand Down