Skip to content

Commit

Permalink
refactor(pr): refactor based on PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrieluizramos committed May 6, 2020
1 parent beb1af7 commit 7612c2e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
2 changes: 0 additions & 2 deletions packages/gatsby/src/bootstrap/remove-stale-jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ export const removeStaleJobs = (
// If any of our pending jobs do not have an existing inputPath or the inputPath changed
// we remove it from the queue as they would fail anyway
state.jobsV2.incomplete.forEach(({ job, plugin }: IGatsbyJobV2): void => {
if (!job) return

if (isJobStale(job)) {
actions.push(internalActions.removeStaleJob(job.contentDigest))
} else {
Expand Down
14 changes: 10 additions & 4 deletions packages/gatsby/src/redux/reducers/jobsv2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ export const jobsV2Reducer = (
case `CREATE_JOB_V2`: {
const { job, plugin } = action.payload

if (!job) return state
if (!job) {
throw new Error(
`If you encounter this error, it's probably a Gatsby internal bug. Please open an issue reporting us this.`
)
}

state.incomplete.set(job.contentDigest, {
job,
plugin,
})
} as IGatsbyJobV2)

return state
}
Expand All @@ -26,7 +30,9 @@ export const jobsV2Reducer = (
const { job } = state.incomplete.get(jobContentDigest) as IGatsbyJobV2

if (!job) {
return state
throw new Error(
`If you encounter this error, it's probably a Gatsby internal bug. Please open an issue reporting us this.`
)
}

state.incomplete.delete(job.contentDigest)
Expand All @@ -35,7 +41,7 @@ export const jobsV2Reducer = (
state.complete.set(job.contentDigest, {
result,
inputPaths: job.inputPaths,
})
} as IGatsbyJobV2)

return state
}
Expand Down
8 changes: 4 additions & 4 deletions packages/gatsby/src/redux/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ export interface IGatsbyJobContent {
}

export interface IGatsbyJobV2 {
job?: IGatsbyJobContent
plugin?: IGatsbyPlugin
job: IGatsbyJobContent
plugin: IGatsbyPlugin
traceId?: string
result?: string[]
inputPaths?: string[]
result: string[]
inputPaths: string[]
}

export interface IGatsbyState {
Expand Down

0 comments on commit 7612c2e

Please sign in to comment.