Worker is canceled when exporting with PDF MIME type

Hello! My worker is canceled when making a Google Drive export PDF API call. The odd thing is the worker is only canceled when triggered via a webhook call (POST) from the Google Drive watch API and changing the mimeType for the export request to text/plain instead of application/pdf; then the export completes successfully. Invoking the worker with a POST request via Postman or GET request, the worker exports the file successfully with the application/pdf mime type. Is there a limitation with Workers and exporting PDFs via the Google Drive API?

Please let me know if there’s any additional detail I can provide, and thanks in advance!

I managed to get the Google Drive export PDF API call working by passing the request Promise to waitUntil.

export default {
  async fetch(request, env, ctx) {
     
     ...

     ctx.waitUntil(
         fetch(`https://www.googleapis.com/drive/v3/files/${fileId}/export?mimeType=application/pdf`, ...)
         .then(response => response.blob())
         .then(blob => env.BUCKET.put("file-name"), blob)
     )

     ...

      return new Response(...)

  }
}

Using async/await without waitUntil is still causing the worker to be canceled. Hope this will help someone looking to export files via the Google Drive API and Workers.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.