Quiet the logs and capture the errors that were missing
- Activity page: "Delete all" empties the open tab (api/admin/logs/clear-logs, super admin only, logged under system) - Stop logging every WebSocket connect - Log unexpected API errors (safeErrorMessage -> logUnexpectedError), every failed bot job attempt and every job the queue lost - Drop the cron jobs' console output; a failed model sync goes to the logs Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -87,7 +87,7 @@ export default async function fireCronJob({ cron_job, now = Date.now() }: Params
|
||||
metadata: { cron_job_id: id, job_id, bot_id: cron_job.bot_id },
|
||||
});
|
||||
} catch (error) {
|
||||
await saveRun({ id, last_error: safeErrorMessage({ error, fallback: `Couldn't queue the run.` }) });
|
||||
await saveRun({ id, last_error: safeErrorMessage({ error, fallback: `Couldn't queue the run.`, log: false }) });
|
||||
|
||||
await logError({
|
||||
title: `Schedule #${id} couldn't run`,
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import { logError } from "./logger";
|
||||
|
||||
type Params = {
|
||||
error: unknown;
|
||||
};
|
||||
|
||||
/**
|
||||
* Writes an error nobody meant to show (anything but an `AppError`) to the
|
||||
* logs, so a failure the client only sees as "Something went wrong" is
|
||||
* still on the Activity page with its stack. Never during tests, which
|
||||
* throw plain errors on purpose, and never throws.
|
||||
*/
|
||||
export default function logUnexpectedError({ error }: Params) {
|
||||
if (process.env.NODE_ENV == "test") return;
|
||||
|
||||
const name = error instanceof Error ? error.name : typeof error;
|
||||
|
||||
void logError({
|
||||
title: `Unexpected server error (${name})`,
|
||||
error,
|
||||
}).catch(() => {});
|
||||
}
|
||||
Reference in New Issue
Block a user