ItzNotABug / ghosler

Send newsletter emails to your Ghost CMS subscribers & members, using your own email credentials!
Apache License 2.0
40 stars 5 forks source link

TypeError [ERR_INVALID_URL]: Invalid URL #48

Closed jubi-git closed 3 months ago

jubi-git commented 3 months ago
          It looks this error returned?

[2024-04-04 11:18:32 UTC] => [ERROR] => Newsletter: TypeError [ERR_INVALID_URL]: Invalid URL at new NodeError (node:internal/errors:405:5) at new URL (node:internal/url:676:13) at Element.<anonymous> (file:///usr/src/app/utils/newsletter.js:238:29) at LoadedCheerio.each (file:///usr/src/app/node_modules/cheerio/lib/esm/api/traversing.js:461:26) at #injectUrlTracking (file:///usr/src/app/utils/newsletter.js:229:45) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Newsletter.renderTemplate (file:///usr/src/app/utils/newsletter.js:148:19) at async Newsletter.send (file:///usr/src/app/utils/newsletter.js:33:60)

Originally posted by @jubi-git in https://github.com/ItzNotABug/ghosler/issues/36#issuecomment-2036908324

ItzNotABug commented 3 months ago

Hey 👋, Could you provide the ghosler version?

As per the error, it looks there's an invalid url in the content. Is it possible that your post content has a malformed url?

jubi-git commented 3 months ago

I am using 0.96 using the docker image

Since I am in a testing environment, I triggered the newsletter using sequential unpublish -> publish

jubi-git commented 3 months ago

Just noticed I had 2 webhooks active. I think because I manually edited the webhook to add the 2369 port; since this is different from the Ghosler config GUI setting, I think an other webhook was added.

ItzNotABug commented 3 months ago

Yes, for every instance that you have and save the settings, a new webhook will be created if one doesn't exist with a similar url. But that shouldn't trigger an error like this from the new URL(elementUrl).host call. The error states that the function call is not able to get the host of a url.

Could you share the post content or maybe check for these tags - a, img, iframe and their respective set urls?

jubi-git commented 3 months ago

I created several posts sequentially and don't remember which one triggered this error. (There is no error or log file other than the console right?) Perhaps it was a post where I did not specify an header image. However I cannot replicate this issue with the post I created thusfar.

ItzNotABug commented 3 months ago

I see. Although this isn't a big issue but I think it should be a good idea to log this under errors and provide the wrong URL instead of crashing the app.

I'll create a patch and instead log an error on console.

ItzNotABug commented 3 months ago

This is patched now in 0.97. Updates on ghosler-cli & docker registry will be available soon.