GithubHelp home page GithubHelp logo

Comments (4)

DavidWells avatar DavidWells commented on July 20, 2024 1

Sounds like response.formats is undefined or not an array here winstonma@4943baa#diff-ef15b8379e2c69cbf9fc5eb96c161ee3R12

Add a console.log(response.formats) and a check to verify that value exists before calling the ytdl.chooseFormat function

from functions.netlify.com.

winstonma avatar winstonma commented on July 20, 2024

Thanks @DavidWells. I added the console.log and confirm that response.formats only have content half of the time, when it is deployed.

When I download my own repo and run locally there is no problem, but the error exist only when it is deployed on Netlify.

May I rewrite my test case here:

  • Run the Youtube API using the browser, and run it multiple times (browser refresh).
  • Run the Youtube (Full) API using the browser, and run it multiple times (browser refresh).

I observe that the first API runs perfectly but the second API only works 50% of the time. Since these 2 APIs are using the same ytdl-core so I would likely to rule out the problem is caused by the module. But I am not sure if the few additional lines of the Full version causes the Netlify function to break.

Additional question:
I would like to attach the Netlify Function log, after calling the API multiple times:

8:30:33 AM: Duration: 7.92 ms Memory Usage: 96 MB
8:30:36 AM: Duration: 721.67 ms Memory Usage: 96 MB
8:30:39 AM: Duration: 10.96 ms Memory Usage: 96 MB
8:31:33 AM: Duration: 641.21 ms Memory Usage: 96 MB
8:31:36 AM: Duration: 4.93 ms Memory Usage: 96 MB
8:31:46 AM: Duration: 697.44 ms Memory Usage: 96 MB

Since the API calls are independent, I would expect the API call duration is more or less similar. However the log shows that the duration of Netlify Function is not flat, and instead the duration value of every other calls are too low that it seems it didn't collect the data from the Youtube Server. This behavior exist when the same API parameter is being used (e.g. browser refresh) and it doesn't applies when parameter is changed between API calls. Here is another example:

  1. Run the Youtube (Full) API with parameter (UVV80kTudSM)
  2. Run the Youtube (Full) API with parameter (DylgPyQxDiI)
  3. Loop through Step 1 and Step 2

When I run the above sequence, the Youtube (Full) API works fine. The API fails only when the same API (with the same parameter) is being called again. Therefore it seems to me that the Netlify Function would use the cached result when the same API parameter is being used again.

Thanks again for your time.

from functions.netlify.com.

winstonma avatar winstonma commented on July 20, 2024

Hi @DavidWells Do you know if Netlify Server cache request? If yes is it possible that I could disable this caching behavior?

from functions.netlify.com.

winstonma avatar winstonma commented on July 20, 2024

I closed this issue because the function is working after I updated the Javascript library.

from functions.netlify.com.

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.