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

TypeError [ERR_INVALID_ARG_TYPE]: The "url" argument must be of type string. Received null On V4.0.1 #759

Closed
MatteZ02 opened this issue Oct 31, 2020 · 4 comments
Labels

Comments

@MatteZ02
Copy link
Contributor

Full error stack:
TypeError [ERR_INVALID_ARG_TYPE]: The "url" argument must be of type string. Received null
at validateString (internal/validators.js:124:11)
at Url.parse (url.js:159:3)
at urlParse (url.js:154:13)
at Url.resolve (url.js:667:29)
at Object.urlResolve [as resolve] (url.js:663:40)
at exports.getInfo (C:\Users\matte\Documents\GitHub\Musix\node_modules\ytdl-core\lib\info.js:260:32)
at runMicrotasks ()
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Map.getOrSet (C:\Users\matte\Documents\GitHub\Musix\node_modules\ytdl-core\lib\cache.js:24:19)
at async Object.default_1 [as handleVideo] (C:\Users\matte\Documents\GitHub\Musix\build\struct\functions\handleVideo.js:12:23) {
code: 'ERR_INVALID_ARG_TYPE'
}

I did some digging to the code and seems like on line 121 of info.js the const getHTML5player returns null due to html5playerRes being null.
I can do some further debugging if thats needed.

@ErikSzabo
Copy link

Looks like this regex change solved the entire problem for me:

const getHTML5player = body => {
  let html5playerRes = /"jsUrl":"([^"]+)"/.exec(body);
  return html5playerRes ? html5playerRes[1] : null;
};

The original regex which searches for a script tag is sometimes failing beacuse the response does not include the specific script tag.

@ultrasamad
Copy link

ultrasamad commented Nov 1, 2020

I'm also getting this error all of a sudden. I don't used to get it

UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "url" argument must be of type string. Received undefined

@fent
Copy link
Owner

fent commented Nov 1, 2020

Looks like this regex change solved the entire problem for me:

thanks for this

@fent fent added the bug label Nov 1, 2020
@MatteZ02
Copy link
Contributor Author

MatteZ02 commented Nov 1, 2020

I'll have to try that regex change. If it works like a charm might do a pr to fix it.

@fent fent closed this as completed in bd8ceca Nov 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants