Refactored the current approach of catching errors and returning null instead of throwing errors in PeopleHR API requests. The former logic has been causing Next.js's data fetching/rendering methods to return a 404 page, instead of relying on it's fallback caching to render the previous cached version of the page when we are unable to query PeopleHR (Note people HR's API is unreliable).
This will also mean that builds will fail when we can't fetch data from people HR which should be the correct behaviour.
I tested locally by randomly throwing an error inside fetchPeopleHRFeed and using npm run build && npm run start in order to use caching (npm run dev will not use Next.js's caching).
/* eslint-disable no-console */
console.log("Fail to fetch people HR feed", new Date().getMinutes() % 2 === 0)
if (new Date().getMinutes() % 2 === 0) throw new Error('rand error');
MR Checklist
[ ] Add a description of your pull request and instructions for the reviewer to verify your work.
[ ] If your pull request is for a specific ticket, link to it in the description.
[ ] Stay on point and keep it small so the merge request can be easily reviewed.
[ ] Consider adding unit tests, especially for bug fixes. If you don't, tell us why.
[ ] Tests and linting passes.
[ ] Consider updating documentation. If you don't, tell us why.
[ ] If relevant, list the environments / browsers in which you tested your changes.
Description of Changes Made
Refactored the current approach of catching errors and returning null instead of throwing errors in PeopleHR API requests. The former logic has been causing Next.js's data fetching/rendering methods to return a 404 page, instead of relying on it's fallback caching to render the previous cached version of the page when we are unable to query PeopleHR (Note people HR's API is unreliable).
This will also mean that builds will fail when we can't fetch data from people HR which should be the correct behaviour.
How to Test
Link to changes made on preview site
I tested locally by randomly throwing an error inside
fetchPeopleHRFeed
and usingnpm run build && npm run start
in order to use caching (npm run dev
will not use Next.js's caching).MR Checklist