Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(logs): add special case for axios error to prevent huge error messages #2468

Merged
merged 1 commit into from
Mar 2, 2025
Merged
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
12 changes: 10 additions & 2 deletions packages/cron-jobs-core/src/creator.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { AxiosError } from "axios";
import cron from "node-cron";

import { Stopwatch } from "@homarr/common";
Expand Down Expand Up @@ -48,8 +49,15 @@ const createCallback = <TAllowedNames extends string, TName extends TAllowedName
}
await creatorOptions.onCallbackSuccess?.(name);
} catch (error) {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
creatorOptions.logger.logError(`Failed to run job '${name}': ${error}`);
// Log AxiosError in a less detailed way to prevent very long output
if (error instanceof AxiosError) {
creatorOptions.logger.logError(
`Failed to run job '${name}': [AxiosError] ${error.message} ${error.response?.status} ${error.response?.config.url}\n${error.stack}`,
);
} else {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
creatorOptions.logger.logError(`Failed to run job '${name}': ${error}`);
}
await creatorOptions.onCallbackError?.(name, error);
}
};
Expand Down
Loading