Skip to content

Commit

Permalink
fix(gatsby): temporary workaround for stale jobs cache (#33586)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladar authored and axe312ger committed Nov 9, 2021
1 parent 536948b commit f7f363a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/gatsby/src/redux/reducers/jobsv2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ export const jobsV2Reducer = (
case `SET_JOB_V2_CONTEXT`: {
const { requestId, job } = action.payload

// A workaround for a stale cache bug:
// in some edge case redux cache is not cleared (even after gatsby-config and package.json changes).
// TODO: figure out the root cause and remove this workaround (see also CLEAR_JOB_V2_CONTEXT)
if (!state.jobsByRequest) {
state.jobsByRequest = new Map()
}
let jobs = state.jobsByRequest.get(requestId)
if (!jobs) {
jobs = new Set<string>()
Expand All @@ -90,6 +96,9 @@ export const jobsV2Reducer = (

case `CLEAR_JOB_V2_CONTEXT`: {
const { requestId } = action.payload
if (!state.jobsByRequest) {
state.jobsByRequest = new Map()
}
state.jobsByRequest.delete(requestId)
}
}
Expand Down

0 comments on commit f7f363a

Please sign in to comment.