From 8b3574d84cbc110db2e3094865731566ca700ecd Mon Sep 17 00:00:00 2001 From: nexryai Date: Tue, 5 Mar 2024 09:20:07 +0900 Subject: [PATCH] fix (backend): stop sending stack traces on API errors Co-authored-by: naskya --- packages/backend/src/server/api/call.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/server/api/call.ts b/packages/backend/src/server/api/call.ts index 1fc42d43cf..083ab18a39 100644 --- a/packages/backend/src/server/api/call.ts +++ b/packages/backend/src/server/api/call.ts @@ -2,6 +2,7 @@ import { performance } from "perf_hooks"; import type Koa from "koa"; import type { CacheableLocalUser } from "@/models/entities/user.js"; import type { AccessToken } from "@/models/entities/access-token.js"; +import { v4 as uuid } from "uuid"; import { getIpHash } from "@/misc/get-ip-hash.js"; import { limiter } from "./limiter.js"; import type { IEndpointMeta } from "./endpoints.js"; @@ -177,7 +178,8 @@ export default async ( if (e instanceof ApiError) { throw e; } else { - apiLogger.error(`Internal error occurred in ${ep.name}: ${e.message}`, { + const errorId = uuid(); + apiLogger.error(`Internal error occurred in ${ep.name}: ${e.message} (Event ID: ${errorId})`, { ep: ep.name, ps: data, e: { @@ -188,9 +190,8 @@ export default async ( }); throw new ApiError(null, { e: { - message: e.message, + message: `Internal error (Event ID: ${errorId})`, code: e.name, - stack: e.stack, }, }); }