torchbox / careers

Torchbox careers site
https://torchbox.com/careers
4 stars 1 forks source link

Fix Page caching #103

Closed Morsey187 closed 1 year ago

Morsey187 commented 1 year ago

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 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