Skip to content

Commit

Permalink
Wrap the download in try/catch in case it fails
Browse files Browse the repository at this point in the history
  • Loading branch information
Dartoxian committed Dec 5, 2023
1 parent b93b22b commit aa23ef5
Showing 1 changed file with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useCallback, useEffect, useState } from "react";
import { useKurtosisClient } from "../../../../../client/enclaveManager/KurtosisClientContext";
import { LogViewer } from "../../../../../components/enclaves/logs/LogViewer";
import { LogLineMessage } from "../../../../../components/enclaves/logs/types";
import { assertDefined, isDefined } from "../../../../../utils";
import { assertDefined, isDefined, stringifyError } from "../../../../../utils";
import { EnclaveFullInfo } from "../../../types";

const serviceLogLineToLogLineMessage = (lines: string[], timestamp?: Timestamp): LogLineMessage[] => {
Expand Down Expand Up @@ -46,18 +46,23 @@ export const ServiceLogs = ({ enclave, service }: ServiceLogsProps) => {
async function* () {
const abortController = new AbortController();
const logs = await kurtosisClient.getServiceLogs(abortController, enclave, [service], false, 0, true);
for await (const lineGroup of logs) {
const lineGroupForService = lineGroup.serviceLogsByServiceUuid[service.serviceUuid];
assertDefined(
lineGroupForService,
`Log line response included a line group withouth service ${
service.serviceUuid
}: ${lineGroup.toJsonString()}`,
);
const parsedLogLines = serviceLogLineToLogLineMessage(lineGroupForService.line, lineGroupForService.timestamp);
for (const parsedLine of parsedLogLines) {
yield parsedLine.message || "";
try {
for await (const lineGroup of logs) {
const lineGroupForService = lineGroup.serviceLogsByServiceUuid[service.serviceUuid];
assertDefined(
lineGroupForService,
`Log line response included a line group withouth service ${
service.serviceUuid
}: ${lineGroup.toJsonString()}`,
);
const parsedLogLines = serviceLogLineToLogLineMessage(
lineGroupForService.line,
lineGroupForService.timestamp,
);
yield parsedLogLines.map((line) => line.message || "").join("\n");
}
} catch (err: any) {
console.error(stringifyError(err));
}
},
[enclave, service],
Expand Down

0 comments on commit aa23ef5

Please sign in to comment.