-
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
refactor(gatsby): enable running of static/page queries separately #12891
Conversation
@KyleAMathews this fixes the
|
} | ||
}, | ||
store: FastMemoryStore(), | ||
} | ||
} |
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.
I think we want to keep those - those add extra overhead which is only needed in watch mode - but for production builds we don't really benefit from those
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.
Oh wow, that was accidental. I didn't mean to delete that part. Great catch
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.
Resolved in 60d1241. In my future branch, the websocket stuff is passed in by gatsby develop, so cleans up this file further.
Can you expand, why splitting query running is needed? Not including page queries result paths in file that gets webpacked seems like would achieve same result without touching so much code? What am I missing? |
Each page query result will now be in its own
The compilation hash references the latest webpack compilation. So each |
cleanup bootstrap moved page-query-runner to index use finishBootstrap() fix query-runner type annotation refactor query-runner/index doc sections queryjobs refactor make query refactor enqueueQueryID -> enqueueExtractedQueryId
498227e
to
e85d723
Compare
@pieh I'm trying to break up my huge |
Couldn't we just append the |
It's more disk I/O but should be relatively cheap. Tried googling how to append to a JSON file (which would be cheapest) but it doesn't look straightforward. We should be fine though since files will almost always be < 100kb. |
if (!isBootstrapping) { | ||
queue.resume() | ||
/** | ||
* Creates a queue that is optimized for running as a daemon during |
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.
curious about the terminology — a daemon is normally a separate process right?
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, I'm not sold on daemon
as terminology either. I'm trying to communicated that it's a long running process that won't end. Other ideas? startListener
, startProcess
?
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.
@pieh and I and some others have talked about modelling more of Gatsby's internals after the Actor Model. It's a larger discussion to conclude if we want to do that but "startActor" would be a natural name then.
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.
If it is actually an actor, then for sure :). But until then, we should probably stick to something generic so we don't confuse people (and yes, daemon
is also a bit confusing).
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.
If it believes it's an actor it is! Haha.
Service is a nice generic name :-)
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.
Yep, I like service. Will change
Just caught up with @KyleAMathews and we chatted about this. While we could figure out a way to load/rewrite the In fact, it enables interesting possibilities like running |
I've made a few more changes downstream of this branch. I'm going to close this and reopen (or recreate) once those changes are settled. |
Description
As part of my work to remove the global
data.json
, I need to run thebuild-javascript
step after static queries have been run, but before page queries. This is because each page result file also includes the webpack build's compilation hash, so that the running app can be invalidated if a rebuild occurs while a user is navigating the page (more info in #11982).While I was doing this refactor, I also took the opportunity to remove a bunch of global state/event emitters. The biggest is that the query queue is now instantiable. So now we can create a queue that processes the static queries, and then create a new one that processes the page queries. Then, we can start a fresh queue processor once gatsby develop has started. Hopefully it makes that part of the code easier to reason about.
I also took a stab at making the calculation of dirty queryIds a bit easier to read. It's not great, but hopefully these changes make it a little easier to understand.
page-query-runner
has becomeindex
. Apologies for the lack of a good diff, but a lot of that file has changed. I have a follow up branch that movessrc/internal-plugins/query-runner/
tosrc/query/
Related Issues