Skip to content

Commit

Permalink
fix: Timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
amaury1093 committed Dec 13, 2023
1 parent edc1502 commit f52dba0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/pages/api/v0/check_email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { Tables } from "@/supabase/database.types";

// https://vercel.com/changelog/serverless-functions-can-now-run-up-to-5-minutes
export const maxDuration = 30000;
export const runtime = "nodejs"; // https://github.com/orgs/vercel/discussions/4248#discussioncomment-7310341

const TIMEOUT = 90000;
const MAX_PRIORITY = 5; // Higher is faster, 5 is max.
Expand Down Expand Up @@ -172,10 +173,12 @@ const POST = async (
console.log(`[🐢] sendToQueue: ${Math.round(d4)}ms`);

setTimeout(() => {
const d10 = performance.now() - startTime;
console.log(`[🐢] Timeout error: ${Math.round(d10)}ms`);
res.status(504).json({
error: `The email ${
(req.body as CheckEmailInput).to_email
} can't be verified within 1 minute. This is because the email provider imposes obstacles to prevent real-time email verification, such as greylisting. Please try again later.`,
} can't be verified within 90s. This is because the email provider imposes obstacles to prevent real-time email verification, such as greylisting. Please try again later.`,
});
}, TIMEOUT);
} catch (err) {
Expand Down

1 comment on commit f52dba0

@vercel
Copy link

@vercel vercel bot commented on f52dba0 Dec 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.