fix (backend): stop sending stack traces on API errors

Co-authored-by: naskya <m@naskya.net>
This commit is contained in:
nexryai 2024-03-05 09:20:07 +09:00 committed by naskya
parent e303496b5e
commit 8b3574d84c
No known key found for this signature in database
GPG key ID: 712D413B3A9FED5C

View file

@ -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,
},
});
}