title: Timeout in Pdf-html when running on Google Cloud Function
body: <p>We've created a Cloud Function that generates a PDF. The library that we're using is </p>
  
  <p><a href="https://www.npmjs.com/package/html-pdf" rel="nofollow noreferrer">https://www.npmjs.com/package/html-pdf</a></p>
  
  <p>The problem is when we try to execute the </p>
  
  <pre><code>.create() 
  </code></pre>
  
  <p>method it times out with the following errors</p>
  
  <pre><code>"Error: html-pdf: PDF generation timeout. Phantom.js script did not exit.
      at Timeout.execTimeout (/srv/node_modules/html-pdf/lib/pdf.js:91:19)
      at ontimeout (timers.js:498:11)
  </code></pre>
  
  <p>This works fine on localhost but happens when we deploy the function on GCP. </p>
  
  <p>Some solutions we've already tried: </p>
  
  <p><strong>Solution #1</strong>
  Yes we've updated the timeout settings to </p>
  
  <pre><code>const options = {
          format: "A3",
          orientation: "portrait",
          timeout: "100000"
          // zoomFactor: "0.5"
  
          // orientation: "portrait"
        };
  </code></pre>
  
  <p>and it still doesn't work. </p>
  
  <p>here's the final snippet that triggers the PDF function</p>
  
  <pre><code>const options = {
          format: "A3",
          orientation: "portrait",
          timeout: "100000"
          // zoomFactor: "0.5"
  
          // orientation: "portrait"
        };
        try {
          // let pdfRes = await new Promise(async (resolve, reject) =&gt; {
          console.log("Before pdf.create()")
  
          let pdfResponse = await pdf.create(html, options).toFile(localPDFFile, async function (err, res) {
            if (err) {
              console.log(err)
            }
  
            console.log('response of pdf.create(): ', res);
            let uploadBucket = await bucket.upload(localPDFFile, {
              metadata: { contentType: "application/octet-stream" }
            });
  
            let docRef = await db
              .collection("Organizations")
              .doc(context.params.orgId)
              .collection("regulations")
              .doc(context.params.regulationId)
              .collection("reports")
              .doc(context.params.reportId);
  
            await docRef.update({
              pdf: {
                status: "created",
                reportName: pdfName
              }
            });
          });
   } catch (error) {
          console.log('error: ', error);
        }
  ``
  
  </code></pre>