-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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): fix ceateNode hanging in custom resolvers #26716
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { IQueryRunningContext } from "./types" | ||
import { DoneInvokeEvent, assign, ActionFunctionMap } from "xstate" | ||
import { enqueueFlush } from "../../utils/page-data" | ||
import { callApi, markNodesDirty } from "../develop/actions" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Importing from develop actions doesn't feel like the correct thing to do. So I am open to suggestions here! |
||
|
||
export const flushPageData = (): void => { | ||
enqueueFlush() | ||
|
@@ -20,6 +21,8 @@ export const queryActions: ActionFunctionMap< | |
IQueryRunningContext, | ||
DoneInvokeEvent<any> | ||
> = { | ||
callApi, | ||
markNodesDirty, | ||
assignDirtyQueries, | ||
flushPageData, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,9 @@ export const queryStates: MachineConfig<IQueryRunningContext, any, any> = { | |
SOURCE_FILE_CHANGED: { | ||
target: `extractingQueries`, | ||
}, | ||
ADD_NODE_MUTATION: { | ||
actions: [`markNodesDirty`, `callApi`], | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunely this won't do what you expect. As this is a child machine, the action is run against the context of the child machine, so marking nodes as dirty won't do anything. |
||
}, | ||
context: {}, | ||
states: { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than forwarding it to the child machine, it should run the action in the current machine. See the
initializingData
state for an example.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The trouble here is that this is not supposed to run them immediately: the reason we do this deferral is so that nodes aren't mutated during query runs. Changing this would mean that we'd be back to how it was without any deferral. Now that might be what we want to do after all, but at that point it would be better to remove the whole deferral system.
I think we need a different way of solving this though, which is probably a more granular way of dealing with deferred resolver mutations, i.e. not waiting until
waiting
, but bailing and drainign earlier.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's what I thought. This was just a quick and direct attempt to address this problem but I see that it defeats the whole purpose of node deferring. We can definitely have a call/chat tomorrow as I'd like to get more context (haha) on our state charts in general. CC @wardpeet