Skip to content

Commit

Permalink
Add missing await/flush in API endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadorequest committed Jun 25, 2021
1 parent 1542318 commit f0d44ad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/modules/core/i18n/middlewares/localeMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const localeMiddleware = async (req: NextApiRequest, res: NextApiResponse
localeFound = customer?.availableLanguages?.[0] || DEFAULT_LOCALE;
}

logEvent(AMPLITUDE_EVENTS.API_LOCALE_MIDDLEWARE_INVOKED, null, {
await logEvent(AMPLITUDE_EVENTS.API_LOCALE_MIDDLEWARE_INVOKED, null, {
locale: localeFound,
});

Expand Down
9 changes: 9 additions & 0 deletions src/pages/api/startVercelDeployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import dispatchWorkflowByPath from '@/modules/core/githubActions/dispatchWorkflo
import { createLogger } from '@/modules/core/logging/logger';
import { ALERT_TYPES } from '@/modules/core/sentry/config';
import { configureReq } from '@/modules/core/sentry/server';
import { flushSafe } from '@/modules/core/sentry/universal';
import * as Sentry from '@sentry/node';
import size from 'lodash.size';
import {
Expand Down Expand Up @@ -141,6 +142,8 @@ const startVercelDeployment = async (req: EndpointRequest, res: NextApiResponse)
Sentry.captureException(new Error(errorMessage));
logger.error(errorMessage);

await flushSafe();

return redirect(res, redirectTo, statusCode);
}

Expand All @@ -159,6 +162,8 @@ const startVercelDeployment = async (req: EndpointRequest, res: NextApiResponse)
Sentry.captureException(new Error(errorMessage));
logger.error(errorMessage);

await flushSafe();

return redirect(res, redirectTo, statusCode);
}

Expand All @@ -167,6 +172,8 @@ const startVercelDeployment = async (req: EndpointRequest, res: NextApiResponse)
Sentry.captureException(new Error(errorMessage));
logger.error(errorMessage);

await flushSafe();

return redirect(res, redirectTo, statusCode);
}

Expand All @@ -179,6 +186,8 @@ const startVercelDeployment = async (req: EndpointRequest, res: NextApiResponse)
Sentry.captureException(e);
logger.error(e.message);

await flushSafe();

res.json({
error: true,
message: process.env.NEXT_PUBLIC_APP_STAGE === 'production' ? undefined : e.message,
Expand Down

0 comments on commit f0d44ad

Please sign in to comment.