Skip to content

RSS feed error handling #15476

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

Merged
merged 11 commits into from
Jun 2, 2025
Merged

RSS feed error handling #15476

merged 11 commits into from
Jun 2, 2025

Conversation

wackerow
Copy link
Member

@wackerow wackerow commented May 19, 2025

Description

  • Adds try/catch blocks to RSS feed fetching
  • If feed not found, or invalid type, throws error up to parent (fetchRSS)
  • Parent logs any errors thrown, but continues through list without breaking
  • Final check added to make sure fetches resulted in at least 6 (RSS_DISPLAY_COUNT) items, else it throws a breaking error. This allows flexibility for small outages or link changes, but will block anything larger that results in missing items in the front end.

Related Issue

Recent homepage outage from an external rss feed url being changed

Copy link

netlify bot commented May 19, 2025

Deploy Preview for ethereumorg ready!

Name Link
🔨 Latest commit 29e3f12
🔍 Latest deploy log https://app.netlify.com/projects/ethereumorg/deploys/6837a8e34948c600086d4564
😎 Deploy Preview https://deploy-preview-15476--ethereumorg.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
7 paths audited
Performance: 41 (🔴 down 18 from production)
Accessibility: 95 (🟢 up 1 from production)
Best Practices: 83 (🔴 down 16 from production)
SEO: 100 (no change from production)
PWA: 58 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions bot added the tooling 🔧 Changes related to tooling of the project label May 19, 2025
wackerow added 4 commits May 19, 2025 15:29
Pass individual fetch/parse errors from child process and console.warn with parent, continuing processes. Add additional guard to make sure enough blog items were fetch; if less then break build.
handles cases where fetch returns html, but invalid RSS/XML feed
@wackerow wackerow marked this pull request as ready for review May 20, 2025 18:54
Comment on lines +129 to +130
if (allItems.length < RSS_DISPLAY_COUNT)
throw new Error("Insufficient number of RSS items fetched")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't actually breaking the build as-is, since it is contained inside an api function call... 🤔 cc: @pettinarip

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, with the addition of generateStaticParams on the homepage, this throw should properly break the build if the RSS fetch doesn't return the 6 results desired to display on the homepage.

does not break build as intended, only breaks front end
Copy link
Member

@pettinarip pettinarip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By design, the fetches under src/lib/api should throw. The error handling logic should happen at the page level. Currently, the dataLoader layer is capturing these errors and throwing.

The reason this test is not failing is because the flag USE_MOCK_DATA is on in preview deploys. To fully test it, you can override the variable in netlify.toml or in netlify UI config.

}
}
return allItems as RSSItem[][]
return allItems
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function fetch will never throw, is that the intention? if we want to break the build, we should

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want a singular feed to break the build (ie. recent example where one blog changed their feed link)... these cases should just skip over that feed.

BUT, in the event something happens where we don't get ANY feed results, then that should break the build... which was the intent of throwing an error at the end if there aren't enough results.

@wackerow
Copy link
Member Author

By design, the fetches under src/lib/api should throw. The error handling logic should happen at the page level. Currently, the dataLoader layer is capturing these errors and throwing.

The reason this test is not failing is because the flag USE_MOCK_DATA is on in preview deploys. To fully test it, you can override the variable in netlify.toml or in netlify UI config.

Couple things:

1- Netlify: USE_MOCK_DATA is already set to false for this branch

image

But, I didn't test this issue specifically through Netlify (truncating the list of RSS feeds so we don't get an adequate number of responses, which imo should break the build....

2- Locally: I did test locally though, and it builds just fine without breaking when I only have a single RSS feed source listed (which should break it)... USE_MOCK_DATA=false... No errors throw at build, but when I serve that build the homepage breaks:

image image image image image

Copy link
Member Author

@wackerow wackerow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be good to go cc: @pettinarip @corwintines

@@ -127,6 +128,8 @@ const Page = async ({ params }: { params: Promise<{ locale: Lang }> }) => {
)
}

export const generateStaticParams = async () => LOCALES_CODES
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forces homepage to builds paths at build, which allows throw Error to break the build

Comment on lines +129 to +130
if (allItems.length < RSS_DISPLAY_COUNT)
throw new Error("Insufficient number of RSS items fetched")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, with the addition of generateStaticParams on the homepage, this throw should properly break the build if the RSS fetch doesn't return the 6 results desired to display on the homepage.

@wackerow wackerow requested a review from pettinarip May 28, 2025 16:56
Copy link
Member

@pettinarip pettinarip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@pettinarip pettinarip merged commit 66396e7 into dev Jun 2, 2025
6 checks passed
@pettinarip pettinarip deleted the rss-feeds branch June 2, 2025 12:46
This was referenced Jun 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tooling 🔧 Changes related to tooling of the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants