url-metadata icon indicating copy to clipboard operation
url-metadata copied to clipboard

Certain URLs cause Maximum call stack size exceeded

Open mauronr opened this issue 4 years ago • 6 comments

Filing a new issue as I can't reopen #6

Some URLs cause a RangeError: Maximum call stack size exceeded An example of URL is https://lnkd.in/gVeYnv7

The error message is below (the stack trace is truncated, shoing only the snippet below)

/<redacted>/node_modules/domutils/lib/querying.js:83
function findAll(test, elems){
                ^

RangeError: Maximum call stack size exceeded
    at findAll (/<redacted>/node_modules/domutils/lib/querying.js:83:17)
    at findAll (/<redacted>/node_modules/domutils/lib/querying.js:90:27)
    at findAll (/<redacted>/node_modules/domutils/lib/querying.js:90:27)
    at findAll (/<redacted>/node_modules/domutils/lib/querying.js:90:27)
    at findAll (/<redacted>/node_modules/domutils/lib/querying.js:90:27)
    at findAll (/<redacted>/node_modules/domutils/lib/querying.js:90:27)
    at findAll (/<redacted>/node_modules/domutils/lib/querying.js:90:27)
    at findAll (/<redacted>/node_modules/domutils/lib/querying.js:90:27)
    at findAll (/<redacted>/node_modules/domutils/lib/querying.js:90:27)
    at findAll (/<redacted>/node_modules/domutils/lib/querying.js:90:27)

mauronr avatar Jan 12 '21 23:01 mauronr

This is because the URL is not a text file. To avoid that, I change the code a bit to process only when the response header content-type matches /^text\//, for example text/html.

https://github.com/chienwen/url-metadata/commit/f3df2087d8343db88b70266f04cff26e5e40d38f

chienwen avatar Feb 10 '21 14:02 chienwen

Just experienced the same problem. And although I have wrapped the call to "urlMetadata" in a try-catch, it made the whole nodejs app shut down. Is there anything I can do to prevent this happening today already?

Trunksome avatar Feb 24 '21 05:02 Trunksome

This is because the URL is not a text file. To avoid that, I change the code a bit to process only when the response header content-type matches /^text\//, for example text/html.

chienwen@f3df208

@chienwen Do you plan to submit the fix from your forked repo back in here?

mauronr avatar Feb 25 '21 21:02 mauronr

@mauronr yes, this fix is included in PR #37

chienwen avatar Feb 26 '21 12:02 chienwen

Great! I'm sorry I missed checking the PRs before asking. And thanks for looking into it.

mauronr avatar Feb 26 '21 16:02 mauronr

Any update on when this PR will be merged, experiencing the same issue it's kind of blocking?

bieblebrox avatar Apr 21 '21 12:04 bieblebrox

Custom headers are now available as an option in new version 3.0.1 https://www.npmjs.com/package/url-metadata

laurengarcia avatar Apr 18 '23 19:04 laurengarcia