TypeError when Downloading to PDF in Azure App Service: undici failure

Aperta
#1,990 6 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
azure, node.js, typescript
Ambito
api, backend, cloud

Direzione di ricerca

Start with conversionDownloadToPdf and the @microsoft/microsoft-graph-client request using ResponseType.RAW, then compare the local and Azure App Service environments on Node v18.19.1. Inspect the full undici error cause and determine whether ProxyAgent or an officially documented workaround addresses the failure; done means the PDF download works in Azure or the limitation is clearly documented.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Download to PDF Not Working in Azure App Service

I'm running an express app using Node v18.19.1. My endpoint does the following:

  1. Saves a document to a sharepoint folder
  2. Performs the download/convert to pdf
  3. Saves the downloaded pdf to a Mongo db.
  4. Deletes the original file

Steps 1, 2, and 4 use the @microsoft/microsoft-graph-client@3.0.7 package. This all works locally. However, when I deploy it to my Azure App Services (running Windows and Node v18.19.1), it breaks at step 2 with the following error:

TypeError: fetch failed at node:internal/deps/undici/undici:12625:11
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

The conversion download method:

const conversionDownloadToPdf = async (fileItemId) => {
    try {
        console.log(chalk.blue(`Attempting to downloaded file (${fileItemId})...`));

        const response = await client.api(`drives/${process.env.DRIVE_ID}/items/${fileItemId}/content?format=pdf`)
            .responseType(ResponseType.RAW) // ensure raw stream
            .get();

        const stream = await apiRequest.responseType(ResponseType.RAW).get(); // BREAKS HERE

        console.log(chalk.blue(`Stream downloaded. Streaming to buffer...`));
      
        return await toBuffer(stream);
    } catch (error) {
        console.error(chalk.red(`Full error details:`));
        console.error(chalk.red(`Message: ${error.message}`));
        console.error(chalk.red(`Status Code: ${error.statusCode}`));
        console.error(chalk.red(`Code: ${error.code}`));
        console.error(chalk.red(`Stack: ${error.stack}`));
        
        // Log the cause if available (undici errors have this)
        if (error.cause)
            console.error(chalk.red(`Cause: ${JSON.stringify(error.cause, null, 2)}`));

        throw error;
    }
}

Do I need to use that ProxyAgent? Do you have official docs on a workaround?

Lingua principale
TypeScript
Stelle
833
Fork
240
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoftgraph/msgraph-sdk-javascript

Tutte le issue di microsoftgraph/msgraph-sdk-javascript

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.