title: NextJS / vercel - 504 Error 'FUNCTION_INVOCATION_TIMEOUT'
body: <p>Getting this error on one of my pages after deploying to vercel, it all works fine in dev mode.</p>
  <p>I think the problem might be one of my fetch/APIs since it uses the data from the first fetch request as the URL for the second fetch request...</p>
  <p>All of my other pages with different APIs / fetch requests work fine...</p>
  <pre><code>export const fetchData = async (page) =&gt; {
    try {
      const req = await fetch(
        &quot;https://www.productpage.com/new/&quot; +
          page
      );
      const html = await req.text();
      const $ = cheerio.load(html);
  
      let newProducts = [];
  
      for (let i = 1; i &lt; 25; i++) {
        let name = $(`#product_listing &gt; tbody &gt; #_${i} &gt; td:nth-child(2) &gt; a`)
          .text()
          .replace(/\n/g, &quot;&quot;);
        let pageSrc = $(
          `#product_listing &gt; tbody &gt; #_${i} &gt; td:nth-child(2) &gt; a`
        ).attr(&quot;href&quot;);
        const price = $(`#product_listing &gt; tbody &gt;#_${i} &gt; td.price.notranslate`)
          .text()
          .replace(/\n/g, &quot;&quot;);
  
        pageSrc = &quot;https://www.productpage.com&quot; + pageSrc;
  
        const req2 = await fetch(pageSrc); // here it is using data from first fetch for a 2nd request..
        const html2 = await req2.text();
        const $2 = cheerio.load(html2);
  
        const imageSrc = $2(
          &quot;#product-main-image .main-image-inner:first-child img&quot;
        ).attr(&quot;src&quot;);
        const name2 = $2(&quot;#product-details dd:nth-child(2)&quot;)
          .text()
          .replace(/\n/g, &quot;&quot;);
        const brand = $2(&quot;#product-details dd:nth-child(4)&quot;)
          .text()
          .replace(/\n/g, &quot;&quot;);
  
        newProducts.push({
          name: name,
          name2: name2,
          brand: brand,
          pageSrc: pageSrc,
          price: price,
          imageSrc: imageSrc,
        });
      }
  
      return newProducts;
    } catch (err) {}
  };
  
  module.exports = {
    fetchData,
  };
  </code></pre>