Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Form times out on slow submit: fix serverless cold starts

CNV-057Medium impactPartlyBy FunnelGuardPublished Updated
On this page

What this issue is

Many modern sites send form data to a serverless function: a small piece of backend code that the host starts only when a request arrives. If nobody has used it for a while, the host has to boot it first. This delay is called a cold start.

A cold start alone adds a second or two. The real trouble starts when the function then does slow work on top: connecting to a database, calling a CRM, sending an email through SMTP. Together these can pass the function's time limit or the browser's patience. The visitor sees a spinner, an error or nothing, and the lead may or may not be saved.

Where a cold-start submit breaks
  1. Visitor fills formClicks Submit after a quiet period
  2. Function cold startHost boots the code from scratch
  3. Slow workDatabase, CRM and email calls pile up
  4. TimeoutBrowser or host gives up
  5. Lead in inbox and CRMNever arrives or arrives half done

The function times out before it finishes, so everything after it is lost.

Why it costs you leads or sales

Cold starts hit the visitors who arrive after a quiet spell: early morning, weekends, the first click from a new ad campaign. These are often your most valuable first impressions. Because later submits are fast, you and your developer test the form, it works, and the problem looks like a one-off.

A timeout is also messy. The visitor may see an error and leave, or retry and create duplicates. Sometimes the lead is saved but the email or CRM step never ran, so the form looks fine while nothing reaches your team.

Submit time by function stateExample numbers
Submit time by function state (example)Warm, light handler: 0.6 seconds; Cold start, light handler: 2.4 seconds; Cold start, CRM and email inline: 11 seconds0480.62.411Warm, light handlerCold start, light han…Cold start, CRM and e…seconds

Example: illustrative numbers only. A warm function answers quickly; a cold one with slow downstream calls can pass a typical 10-second limit.

How to check if your site has it

Reproduce a cold-start submit
  1. Wait for the function to go idle

    Leave the site alone for 15 to 30 minutes. Idle times vary by host, so try longer if needed.

  2. Open DevTools and submit

    In your browser press F12, open the Network tab, then submit the form with test data. Find the request to your form endpoint and read the Time column.

  3. Compare with a second submit

    Submit again straight away. If the second request is far faster, a cold start is the likely cause.

  4. Read the function logs

    In your host's dashboard (Vercel Functions logs, Netlify Functions, AWS CloudWatch) look for the duration of each call and for timeout or 502/504 errors.

  5. Check the lead landed everywhere

    Confirm the test lead reached the inbox and the CRM, not only that the page showed success.

How to fix it

The core idea is the same everywhere: answer the visitor quickly, and do the slow work separately. Start with the generic steps, then apply the platform notes.

Make the submit path fast and safe
  1. Respond first, work later

    Validate, save the lead to a fast store or queue, return success, then send emails and CRM calls in the background.

  2. Raise the function timeout

    Raise the maximum duration to what your plan allows, as a safety net rather than the main fix.

  3. Slim the function

    Remove unused packages, import only what you need and reuse database connections outside the handler so they survive between calls.

  4. Reduce cold starts

    Use a lighter runtime, a region close to your database, or your host's option for keeping instances warm if your plan offers it.

  5. Add a client timeout and retry message

    If the request takes too long, show a clear message and keep the entered data so the visitor can retry. Use an idempotency key so a retry does not create a duplicate lead.

Platform specifics
  1. Return early

    Save the lead, respond with 200, and hand email and CRM work to a queue or background job.

  2. Set the duration

    On Vercel set maxDuration for the function; on AWS Lambda raise the Timeout setting; on Netlify check the function timeout for your plan.

Client-side timeout with a clear messagejavascript
const form = document.querySelector('form');
form.addEventListener('submit', async (e) => {
  e.preventDefault();
  const controller = new AbortController();
  const timer = setTimeout(() => controller.abort(), 15000);
  try {
    const res = await fetch(form.action, {
      method: 'POST',
      body: new FormData(form),
      signal: controller.signal
    });
    if (!res.ok) throw new Error('Bad response');
    form.innerHTML = '<p>Thanks, we have your message.</p>';
  } catch (err) {
    alert('This is taking longer than usual. Your details are still in the form. Please try again.');
  } finally {
    clearTimeout(timer);
  }
});
Submit handler design

Before

  • Function validates, writes to the database, calls the CRM and sends email before replying
  • A cold start plus slow calls pass the time limit
  • Visitor sees an error or a spinner

After

  • Function validates, saves the lead and replies at once
  • CRM and email run from a queue or background job
  • Visitor sees success and the team gets the lead

How to confirm it's fixed

After the change
  • Wait for the idle period again, then submit a test lead and note the request time
  • The first submit after idle finishes well inside your timeout
  • The success message appears and no error shows
  • The test lead reaches the inbox and the CRM exactly once
  • Function logs show no timeouts or 502/504 responses
  • Retrying after a simulated slow response does not create a duplicate

How to prevent it happening again

Set a submit time budget, for example that the form must answer in under 5 seconds even when cold, and test against it after every deploy. New code, a heavier library or a slower CRM call can quietly push you back over the line.

How a cold-start timeout unfolds
  1. Example: 06:00

    Function has been idle all night

  2. Example: 07:42

    First visitor from an ad submits the form

  3. Example: 07:42 + 12s

    Cold start plus CRM call pass the limit; the request times out

  4. Example: 07:43

    Visitor leaves. Later submits are fast, so nobody notices

Cold start with slow work inlineInteractive
Function is cold and does slow work before replying

Cold and slow

Leads or data lost

The request passes the time limit, the visitor sees an error and the lead may be lost or half processed.

Toggle the cause to see how the submit result changes.

How FunnelGuard handles this

FunnelGuard detects this issue only partly. It runs your real form journey on a schedule and flags a duration anomaly: if a submit takes much longer than usual, or the journey fails, you get one alert after a re-check from a second region, with a screenshot and a likely cause.

What it does not do: it has no submit budget, meaning you cannot set a fixed maximum time for the submit step and be alerted the moment it is crossed. A slow but still successful submit may therefore go unflagged if it is not unusual compared with earlier runs. Scheduled checks also may not land on a cold function every time.

Questions people ask

Why does my contact form time out the first time but work on retry?

Most likely the backend is a serverless function that went idle and had to cold start. The first request pays the start-up time plus any slow database, CRM or email calls, and can pass the time limit. Later requests hit a warm function and finish fast.

What is a serverless cold start?

It is the delay when a host has to start your function from scratch because it has not run recently. It usually adds a second or two, and more if the code is heavy or opens connections on start-up.

How do I stop my serverless form from timing out?

Reply to the visitor as soon as the lead is saved and move slow work such as CRM and email calls to a background queue. Also slim the function, raise the timeout as a safety net and show a clear retry message in the browser.

Can a form timeout lose leads even if the page shows success?

Yes. If the function saves the lead but times out before sending the email or CRM call, the visitor may see success while your team receives nothing. Always check that a test lead reaches the inbox and the CRM.

How can I test a form for cold start problems?

Leave the site idle for 15 to 30 minutes, open DevTools Network, submit the form and read the request time. Then submit again and compare. A big gap between the two means a cold start.

Does keeping a function warm fix the problem?

It helps by removing most cold starts, but it does not fix slow downstream calls. Combine it with a lightweight handler that replies quickly and does the slow work in the background.

Will FunnelGuard alert me when my form submit is slow?

Partly. It flags a duration anomaly when a submit takes unusually long or fails, but it has no fixed submit budget you can set. Keep your own time limit and check function logs too.

Does FunnelGuard catch this?

Partly

FunnelGuard checks part of this.

How: duration anomaly; no submit budget.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.