diff --git a/dashboard/client/src/api.ts b/dashboard/client/src/api.ts index 767ee4a0d..e2ff52464 100644 --- a/dashboard/client/src/api.ts +++ b/dashboard/client/src/api.ts @@ -65,8 +65,8 @@ type ProcessStats = { export type Worker = { pid: number; workerId: string; - logCount: number; - errorCount: number; + logCount?: number; + errorCount?: number; language: string; jobId: string; coreWorkerStats: CoreWorkerStats[]; @@ -167,8 +167,8 @@ type BaseNodeInfo = { }; loadAvg: [[number, number, number], [number, number, number]]; net: [number, number]; // Sent and received network traffic in bytes / second - logCount: number; - errorCount: number; + logCount?: number; + errorCount?: number; }; export type NodeInfoResponse = { diff --git a/dashboard/client/src/pages/dashboard/node-info/features/Errors.tsx b/dashboard/client/src/pages/dashboard/node-info/features/Errors.tsx index cdeaa5ca4..1fbf22520 100644 --- a/dashboard/client/src/pages/dashboard/node-info/features/Errors.tsx +++ b/dashboard/client/src/pages/dashboard/node-info/features/Errors.tsx @@ -13,7 +13,7 @@ import { } from "./types"; const ClusterErrors: ClusterFeatureRenderFn = ({ nodes }) => { - const totalErrCount = sum(nodes.map((node) => node.errorCount)); + const totalErrCount = sum(nodes.map((node) => node.errorCount ?? 0)); return totalErrCount === 0 ? ( No errors @@ -29,26 +29,27 @@ const ClusterErrors: ClusterFeatureRenderFn = ({ nodes }) => { const makeNodeErrors = ( setErrorDialog: (nodeIp: string, pid: number | null) => void, ): NodeFeatureRenderFn => ({ node }) => { - return node.errorCount === 0 ? ( + const errorCount = node.errorCount ?? 0; + return errorCount === 0 ? ( No errors ) : ( setErrorDialog(node.ip, null)}> - View all errors ({node.errorCount.toLocaleString()}) + View all errors ({errorCount.toLocaleString()}) ); }; const nodeErrorsAccessor: Accessor = ({ node }) => - node.errorCount; + node.errorCount ?? 0; const makeWorkerErrors = ( setErrorDialog: (nodeIp: string, pid: number | null) => void, ): WorkerFeatureRenderFn => ({ node, worker }) => { return worker.errorCount !== 0 ? ( setErrorDialog(node.ip, worker.pid)}> - View errors ({worker.errorCount.toLocaleString()}) + View errors ({worker.errorCount?.toLocaleString()}) ) : ( @@ -58,7 +59,7 @@ const makeWorkerErrors = ( }; const workerErrorsAccessor: Accessor = ({ worker }) => - worker.errorCount; + worker.errorCount ?? 0; const makeErrorsFeature = ( setErrorDialog: (nodeIp: string, pid: number | null) => void, diff --git a/dashboard/client/src/pages/dashboard/node-info/features/Logs.tsx b/dashboard/client/src/pages/dashboard/node-info/features/Logs.tsx index 78701ba7a..a370ddbbc 100644 --- a/dashboard/client/src/pages/dashboard/node-info/features/Logs.tsx +++ b/dashboard/client/src/pages/dashboard/node-info/features/Logs.tsx @@ -13,7 +13,7 @@ import { } from "./types"; const ClusterLogs: ClusterFeatureRenderFn = ({ nodes }) => { - const totalLogCount = sum(nodes.map((n) => n.logCount)); + const totalLogCount = sum(nodes.map((n) => n.logCount ?? 0)); return totalLogCount === 0 ? ( No logs @@ -27,27 +27,30 @@ const ClusterLogs: ClusterFeatureRenderFn = ({ nodes }) => { const makeNodeLogs = ( setLogDialog: (nodeIp: string, pid: number | null) => void, -): NodeFeatureRenderFn => ({ node }) => - node.logCount === 0 ? ( +): NodeFeatureRenderFn => ({ node }) => { + const logCount = node.logCount ?? 0; + return logCount === 0 ? ( No logs ) : ( setLogDialog(node.ip, null)}> - View all logs ({node.logCount.toLocaleString()}{" "} + View all logs ({logCount.toLocaleString()}{" "} {node.logCount === 1 ? "line" : "lines"}) ); +}; const nodeLogsAccessor: Accessor = ({ node }) => node.logCount ? sum(Object.values(node.logCount)) : 0; const makeWorkerLogs = ( setLogDialog: (nodeIp: string, pid: number | null) => void, -): WorkerFeatureRenderFn => ({ worker, node }) => - worker.logCount !== 0 ? ( +): WorkerFeatureRenderFn => ({ worker, node }) => { + const logCount = worker.logCount ?? 0; + return logCount !== 0 ? ( setLogDialog(node.ip, worker.pid)}> - View log ({worker.logCount.toLocaleString()}{" "} + View log ({logCount.toLocaleString()}{" "} {worker.logCount === 1 ? "line" : "lines"}) ) : ( @@ -55,9 +58,10 @@ const makeWorkerLogs = ( No logs ); +}; const workerLogsAccessor: Accessor = ({ worker }) => - worker.logCount; + worker.logCount ?? 0; const makeLogsFeature = ( setLogDialog: (nodeIp: string, pid: number | null) => void,