From e4c51cfda44147a0416f10db514050405fb939a1 Mon Sep 17 00:00:00 2001 From: if1live Date: Tue, 3 Oct 2023 14:18:53 +0900 Subject: [PATCH] =?UTF-8?q?sentry=20flush=EB=8A=94=20=EB=AF=B8=EB=93=A4?= =?UTF-8?q?=EC=9B=A8=EC=96=B4=201=EA=B0=9C=EB=A1=9C=20=EB=8C=80=EC=9D=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/app.ts b/src/app.ts index 45aed82..1adeaee 100644 --- a/src/app.ts +++ b/src/app.ts @@ -18,10 +18,9 @@ app.onError(async (err, c) => { const extractStatusCode = (err: any) => err.status ?? err.statusCode ?? 500; const status = extractStatusCode(err); - // 관심있는 에러만 센트리로 취급 + // 관심있는 에러만 센트리로 보낸다 if (status >= 500) { Sentry.captureException(err); - await Sentry.flush(3000); } interface ErrorModel { @@ -73,7 +72,11 @@ app.use("*", compress()); app.use("*", async (_, next) => { await next(); - await Sentry.flush(3000); + + // https://github.com/getsentry/sentry-javascript/blob/develop/packages/serverless/src/awslambda.ts + // flushTimeout은 sentry serverless 정책 가져옴 + const flushTimeout = 2000; + await Sentry.flush(flushTimeout).catch((e) => console.error(e)); }); app.get("/", async (c) => {