Git Product home page Git Product logo

Comments (7)

ejizba avatar ejizba commented on August 21, 2024 1

No problem, glad you got it figured out!

There's some known issues around the timing/ordering of context.log. The host team made some changes recently to address this, but it'll be slow to roll out. The fix may or may not have helped in your case
Azure/azure-functions-nodejs-library#191
Azure/azure-functions-host#9238

from azure-functions-nodejs-worker.

mfontes avatar mfontes commented on August 21, 2024

I wanted to add this as a separate comment rather than detract from the original, but I did notice this very odd bit of behavior. If I throw an error immediately after the file download, it looks like the file download completes in a reasonable amount of time:

  const fileBuffer = await blobClient.downloadToBuffer(0, undefined, {
    blockSize: Math.pow(2, 10) * 256,
    onProgress: function ({ loadedBytes }) {
      context.log(`progress! ${loadedBytes} of ${contentLength}`);
    },
  });
  throw new Error('blah');

This logs to the console:

[2024-01-19T22:39:25.925Z] progress! 262144 of 1311223
[2024-01-19T22:39:25.936Z] progress! 524288 of 1311223
[2024-01-19T22:39:25.938Z] progress! 524791 of 1311223
[2024-01-19T22:39:25.944Z] progress! 786935 of 1311223
[2024-01-19T22:39:25.952Z] progress! 1049079 of 1311223
[2024-01-19T22:39:25.961Z] progress! 1311223 of 1311223
[2024-01-19T22:39:25.961Z] Error: blah

Note the timestamps --- there is very little delay between retrieving all of the blocks. The whole download completes in ~36ms. Of course, throwing an error does me no good as it fails my function execution. Swallowing the error in a try/catch just reproduces the original behavior

from azure-functions-nodejs-worker.

ejizba avatar ejizba commented on August 21, 2024

What version of @azure/storage-blob are you using? That being said, it's weird to me that it fails when you send an http.get request without even using the @azure/storage-blob package. That indicates the package theoretically isn't the problem

Could you share the files you're using to test? I'm curious if there's anything weird/unique about them. I used the command mkfile -n 2m 2m to make a 2mb file (not json though) and your code worked just fine for me locally.

from azure-functions-nodejs-worker.

mfontes avatar mfontes commented on August 21, 2024

Hi @ejizba,

We're using @azure/storage-blob ^12.17.0 which I believe is the latest version currently. But like you said, it doesn't appear to be related to that package considering a standard http get request hangs in the same way.

Here is a sample ~2mb file that I am having trouble downloading
Here is a sample 1.3mb file that I can download, but only after a 3.5 minute hang

from azure-functions-nodejs-worker.

mfontes avatar mfontes commented on August 21, 2024

Also confirming I tried mkfile -n 2m 2m to generate a file, and I am able to download the file successfully without any hanging.

from azure-functions-nodejs-worker.

ejizba avatar ejizba commented on August 21, 2024

The sample file worked fine for me 🤷‍♂️. Maybe it's something unique about your storage account? You could try a fresh new storage account if you think that could be contributing

from azure-functions-nodejs-worker.

mfontes avatar mfontes commented on August 21, 2024

@ejizba sorry for bothering you with this. I determined the root cause was in our function app code. After downloading from blob storage, we had a bit of poorly performing code that was taking a long time to operate on the downloaded blob.

It looked like the blob was never finished downloading because I couldn't log the progress to 100%, but it appears that has something to do with using context.log before a long and resource-intensive process is occurring? If I switched to console.log I could see that my code was still executing and stuck in a long-running loop. Fixed the long-running loop and the download appears to complete as it should! It also explains why throwing an error after download appeared to finish the download -- the function execution would complete before my long-running loop could start.

from azure-functions-nodejs-worker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.