Skip to content
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

fix(gatsby): Use xstate predictableActionArguments & update to 4.34 #36342

Merged
merged 13 commits into from
Nov 17, 2022
Prev Previous commit
Revert "Use pendingQueryRuns available on the event (#36393)"
This reverts commit 9460dd3.
  • Loading branch information
LekoArts committed Nov 16, 2022
commit 7b02bb8ba0ce463eadff8c8bc5f41a308ee39f55
13 changes: 5 additions & 8 deletions packages/gatsby/src/services/calculate-dirty-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ import { IGroupedQueryIds } from "./"
import { IQueryRunningContext } from "../state-machines/query-running/types"
import { assertStore } from "../utils/assert-store"

export async function calculateDirtyQueries(
{ store, websocketManager }: Partial<IQueryRunningContext>,
{
pendingQueryRuns: currentlyHandledPendingQueryRuns,
}: {
pendingQueryRuns?: Set<string>
} = {}
): Promise<{
export async function calculateDirtyQueries({
store,
websocketManager,
currentlyHandledPendingQueryRuns,
}: Partial<IQueryRunningContext>): Promise<{
queryIds: IGroupedQueryIds
}> {
assertStore(store)
Expand Down
6 changes: 6 additions & 0 deletions packages/gatsby/src/state-machines/query-running/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,16 @@ export const trackRequestedQueryRun = assign<
},
})

export const clearCurrentlyHandledPendingQueryRuns =
assign<IQueryRunningContext>({
currentlyHandledPendingQueryRuns: undefined,
})

export const queryActions: ActionFunctionMap<IQueryRunningContext, any> = {
assignDirtyQueries,
flushPageData,
markSourceFilesDirty,
markSourceFilesClean,
trackRequestedQueryRun,
clearCurrentlyHandledPendingQueryRuns,
}
12 changes: 9 additions & 3 deletions packages/gatsby/src/state-machines/query-running/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,21 @@ export const queryStates: MachineConfig<IQueryRunningContext, any, any> = {
},
},
calculatingDirtyQueries: {
entry: assign({
pendingQueryRuns: new Set(),
entry: assign<IQueryRunningContext>(({ pendingQueryRuns }) => {
return {
pendingQueryRuns: new Set(),
currentlyHandledPendingQueryRuns: pendingQueryRuns,
}
}),
invoke: {
id: `calculating-dirty-queries`,
src: `calculateDirtyQueries`,
onDone: {
target: `runningStaticQueries`,
actions: [`assignDirtyQueries`],
actions: [
`assignDirtyQueries`,
`clearCurrentlyHandledPendingQueryRuns`,
],
},
},
},
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby/src/state-machines/query-running/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ export interface IQueryRunningContext {
websocketManager?: WebsocketManager
filesDirty?: boolean
pendingQueryRuns?: Set<string>
currentlyHandledPendingQueryRuns?: Set<string>
}