Task timed out randomly after successfully deploy to Netify

I’m doing some side-project with scraping dynamic contents page with chrome-aws-lambda.
After i success to deploy to netlify. Somehow, i get error ERROR Task timed out after 10.01 seconds randomly. . I tried with local development and still working normal ( you can see the log below).

I was follow-up this topic to make my function run-once ( to reduce the load time too) but still get the error

> netlify dev
◈ Netlify Dev ◈
◈ Ignored general context env var: LANG (defined in process)
◈ Ignored general context env var: LANGUAGE (defined in process)
◈ No app server detected and no "command" specified
◈ Using current working directory
◈ Unable to determine public folder to serve files from
◈ Setup a netlify.toml file with a [dev] section to specify your dev server settings.
◈ See docs at: https://cli.netlify.com/netlify-dev#project-detection
◈ Running static server from "scrap-nodeJS"
◈ Loaded function cases.
◈ Loaded function hello.
◈ Functions server is listening on 37945

◈ Server listening to 3999

   │                                                 │
   │   ◈ Server now ready on http://localhost:8888   │
   │                                                 │

◈ Rewrote URL to /.netlify/functions/hello
Request from ::1: GET /.netlify/functions/hello
Response with status 200 in 21 ms.
◈ Rewrote URL to /.netlify/functions/cases
Request from ::1: GET /.netlify/functions/cases
Response with status 200 in 2997 ms.

This is my current code :

const chromium = require('chrome-aws-lambda');
exports.handler = async function (event, context) {
    let browser;
    const launchBrowser = async () => {
        if (browser) return;
        browser = await chromium.puppeteer.launch({
            executablePath: await chromium.executablePath,
            args: chromium.args,
            defaultViewport: chromium.defaultViewport,
            headless: true,
    try {
        await launchBrowser()
        const page = await browser.newPage();
        await page.setRequestInterception(true);
        page.on('request', (req) => {
// prevent render css,img,only render text
            if (req.resourceType() === 'stylesheet' || req.resourceType() == 'font' || req.resourceType() == 'image') {
            } else {
        await page.goto('https://vnexpress.net/covid-19/covid-19-viet-nam');
        const element = await page.waitForSelector('.total_case_today'); // select the element
        const cases = await element.evaluate(el => el.textContent); // grab the textContent from the 
        return {
            statusCode: 200,
            body: JSON.stringify({
                cases: cases

    } catch (error) {
    } finally {

Hi @hoangtho1997

Serverless functions must complete in 10 seconds, background functions within 15 minutes as per docs

oh no. … :frowning: so sad. Any chance to increased the max time?.

The max we can go is 26 seconds. However, we require you to be on a Pro or above team for that.

Oh im just hobyist developer :(. Not Pro developer so it really hard to me to afford it :frowning:

Unfortunately, in that case, you could write your API in a way that might finish within 10 seconds. if you’re depending on a 3-rd party API and that’s taking long, maybe you can switch to another API that might be faster. If that’s not possible, you’d have to host your API elsewhere.