Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot destructure property 'jar' of 'options.agent' as it is undefined #62

Closed
Brainicism opened this issue Aug 4, 2024 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@Brainicism
Copy link

Brainicism commented Aug 4, 2024

Describe the bug

getInfo calls are failing. Is passing an agent with cookies required now? Requiring this by default seems to be a pretty major breaking change, given that most people probably use this library unauthenticated.

TypeError: Cannot destructure property 'jar' of 'options.agent' as it is undefined.
    at fetchIosJsonPlayer (/workspace/node_modules/@distube/ytdl-core/lib/info.js:320:11)
    at exports.getInfo (/workspace/node_modules/@distube/ytdl-core/lib/info.js:245:35)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)}

Seems introduced by 6ddf70d

Debug File

Environment

  • @distube/ytdl-core version: 4.14.0
  • Node.js version: v18.20.3
  • Operating system: Debian GNU/Linux 11
@Brainicism Brainicism added the bug Something isn't working label Aug 4, 2024
@skick1234
Copy link

It is included as a default option, but I cloned options object in getBasicInfo so it won't be passed to getInfo options. It should be resolved now.

@Brainicism
Copy link
Author

Brainicism commented Aug 5, 2024

Getting the same error but in a strange way. If I call getBasicInfo() or getInfo() independently, they will succeed. But if I call either of them one after the other, I still receive the same error as above.

My use-case was, calling getBasicInfo() to check if a video was playable, followed by a ytdl() call to begin downloading, which internally calls getInfo(), which is failing.

I'm assuming this is because getBasicInfo() is supposed to fill the default options (including agent), but the call is being skipped because of the info cache.

node ➜ /workspace (update-ytdl) $ npx ts-node src/ytdl-test.ts 
/workspace/node_modules/@distube/ytdl-core/lib/info.js:322
  const { jar, dispatcher } = options.agent;
          ^
TypeError: Cannot destructure property 'jar' of 'options.agent' as it is undefined.
    at fetchIosJsonPlayer (/workspace/node_modules/@distube/ytdl-core/lib/info.js:322:11)
    at exports.getInfo (/workspace/node_modules/@distube/ytdl-core/lib/info.js:247:35)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    (async () => {
    const x = await ytdl.getBasicInfo(
        "http://www.youtube.com/watch?v=aqz-KE-bpKQ",
    );

    const y = await ytdl.getInfo("http://www.youtube.com/watch?v=aqz-KE-bpKQ");
})();

Created new issue for this here: #63

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants