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

[1.0] make determining when a given stage is finished much more reliable #1080

Merged
merged 13 commits into from
Jun 1, 2017

Conversation

KyleAMathews
Copy link
Contributor

Two main tricks.

One was adding a way to track cascading work e.g. a source plugin adds a node which then transformer plugin takes and creates a new node which then another transformer plugin does more work on and so forth. Before there was no way to know when the last bit of work associated with the initial sourcing was finished. To solve this, I added a traceId which is passed in during the original API call and then all subsequent work passes it along. And rather nicely, this is all hidden from the plugins themselves as we inject the traceId into the actions that plugins create.

Second was moving more internal work into internal plugins. This lets us take advantage of the new tracing capabilities above so that if internal work is triggered by an API call, we're tracking it along with every other plugin.

Now the bootstrap/index.js file is quite straightforward to read especially with our use of async/await. It's now stepping cleanly through each step of the process.

This solves two problems. The biggest is there was occasionally weird graphql errors where some data just wouldn't get processed in time before the debounce timeout. Those should be gone now. The other is the debouncing added time overhead to the bootstrap process. Removing that means bootstrap is sped up by something like 750-1000 milliseconds. Now a barebones Gatsby site's bootstrap can be as fast as 2.5-3 seconds (And most of that time is loading JavaScript so can't wait for prepack.io to get prod ready).

I also snuck in a simple jobs system. gatsby-plugin-sharp (image processing plugin) is the only user atm but it let's plugins tell Gatsby it has long-running jobs going and block bootstrap from finishing while it's working. It should have all the data necessary for building a nice CLI UI @jquense

@gatsbybot
Copy link
Collaborator

gatsbybot commented Jun 1, 2017

Deploy preview ready!

Built with commit 42804c1

https://deploy-preview-1080--using-drupal.netlify.com

@KyleAMathews
Copy link
Contributor Author

Oh and I also added support to the API runner for callback based async. So you can now either return a promise or use the optional third callback argument.

@KyleAMathews
Copy link
Contributor Author

@KyleAMathews
Copy link
Contributor Author

Deploy preview failed.

Built with commit 793119b

https://app.netlify.com/sites/image-processing/deploys/59303449cf321c04c3ac20e8

@KyleAMathews
Copy link
Contributor Author

Deploy preview failed.

Built with commit 793119b

https://app.netlify.com/sites/gatsbygram/deploys/59303448cf321c04c3ac20dc

@KyleAMathews
Copy link
Contributor Author

Deploy preview failed.

Built with commit 793119b

https://app.netlify.com/sites/gatsbyjs/deploys/59303448cf321c04c3ac20da

@KyleAMathews
Copy link
Contributor Author

KyleAMathews commented Jun 1, 2017

@KyleAMathews
Copy link
Contributor Author

KyleAMathews commented Jun 1, 2017

Deploy preview ready!

Built with commit 42804c1

https://deploy-preview-1080--gatsbyjs.netlify.com

@KyleAMathews
Copy link
Contributor Author

KyleAMathews commented Jun 1, 2017

Deploy preview ready!

Built with commit 42804c1

https://deploy-preview-1080--gatsbygram.netlify.com

@jquense
Copy link
Contributor

jquense commented Jun 1, 2017

this is sweet! Should make wrangling console output a lot more straightforward as well :) I can't wait to try on top of this

@KyleAMathews
Copy link
Contributor Author

KyleAMathews commented Jun 1, 2017

Deploy preview failed.

Built with commit 6d10258

https://app.netlify.com/sites/image-processing/deploys/59303e21424ef20be0332dd8

// This fails in tests.
let actions
try {
actions = require(`gatsby/dist/redux/actions`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could use Jest moduleMapper to rewrite these paths back to src in tests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 done

@KyleAMathews
Copy link
Contributor Author

Things are finally all passing but now mysteriously, one of the function names isn't getting parsed. But only on Linux apparently as it works just fine on my mac. Oy!

screen shot 2017-06-01 at 11 41 21 am

Close enough. We'll figure that out another time.

@KyleAMathews KyleAMathews merged commit 7b3bcd5 into 1.0 Jun 1, 2017
@KyleAMathews KyleAMathews deleted the fix-time branch June 1, 2017 18:42
mwfrost pushed a commit to mwfrost/gatsby that referenced this pull request Apr 20, 2023
…ble (gatsbyjs#1080)

* Use 'traceId' to track when cascading actions are complete

* Add jobs system + move query running into internal plugins

* Fixes, remove logging, disable rebuilding schema in dev

* Remove unused code/packages

* Rename variables

* Update snapshots

* Fix building + change postBuild to onPostBuild

* Fix Drupal source plugin/site by restoring way for plugins to set status + touchNode action creator

* Remove console.logs

* debugging

* Use jest moduleNameMapper to fix failing test

* Don't query raw field as we don't use it

* Use standard JSDoc notation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants