defuddle-cli
defuddle-cli copied to clipboard
Parse command for Substack ends with "fetch is not defined" error
Command:
npm run build
npm start parse https://www.henrikkarlsson.xyz/p/why-we-ended-up-homeschooling -- -o test.md -m
Output:
> [email protected] start
> node dist/index.js parse https://www.henrikkarlsson.xyz/p/why-we-ended-up-homeschooling -o test.md -m
Output written to test.md
https://substackcdn.com/bundle/static/js/4255.3caa057c.js:1
<TRUNCATED>
ReferenceError: fetch is not defined
at k (https://substackcdn.com/bundle/static/js/4255.3caa057c.js:1:61396)
at x (https://substackcdn.com/bundle/static/js/4255.3caa057c.js:1:61374)
at eA.onTopReached (https://substackcdn.com/bundle/static/js/4655.05180ce8.js:1:90089)
at Object.onVisible (https://substackcdn.com/bundle/static/js/4655.05180ce8.js:1:88144)
at c.<anonymous> (https://substackcdn.com/bundle/static/js/205.689c287f.js:1:23549)
at o (https://substackcdn.com/bundle/static/js/4255.3caa057c.js:1:82479)
at b.setState (https://substackcdn.com/bundle/static/js/3860.194b2fca.js:2:14474)
at https://substackcdn.com/bundle/static/js/4255.3caa057c.js:1:82509
at new Promise (<anonymous>)
at eN (https://substackcdn.com/bundle/static/js/4255.3caa057c.js:1:82354)
Node.js v18.19.0
The output is successfully generated, but the command ends with a thrown error. The fetch issue is probably due to https://github.com/jsdom/jsdom/issues/1724 while async executing scripts which could be fixed by patching global/window, but I think in this case this error could be avoided by just cleaning up the JSDOM resources and exiting if we already have the output that we care about - will open a PR with the suggestion.