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-dev-cli): increase debounce threshold in CI environments #8387

Merged
merged 7 commits into from
Sep 28, 2018

Conversation

DSchau
Copy link
Contributor

@DSchau DSchau commented Sep 20, 2018

I think this might fix #8381.

I think the process was exiting too quickly in the CI environment, therefore the task was stopped before all the files could copy over.

Also note I tested the issue (not the fix) by sshing to the CircleCI container, and running the following commands

gatsby-dev --scan-once

it would occasionally copy the expected amount of files, and then sometimes 0, leading me to believe this fix may be the trick 🤞

@KyleAMathews
Copy link
Contributor

Huh weird. Who wrote that code 😅

Can't we do a Promise.all on the copying or something to more directly know when the copying is done?

@DSchau
Copy link
Contributor Author

DSchau commented Sep 21, 2018

@KyleAMathews I was refactoring it to go that way. I'll continue that here 😄

@@ -8,21 +8,23 @@ let numCopied = 0
const debouncedQuit = _.debounce(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still need to debounce?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think so. I think the watcher gets triggered pretty often, and so the debounce is necessary so that we don't quit too soon.

That said, that's more of a guess than a firm guarantee 🤷‍♂️

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I see... yeah, on scan-once we should only listen to the ready event then as that's only called once Chokidar has scanned all files https://github.com/paulmillr/chokidar

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Neat :) I'll fix this in a sec. Deep in caching stuff 😅

@DSchau DSchau requested a review from pieh September 26, 2018 14:43
@DSchau DSchau requested a review from a team as a code owner September 26, 2018 15:06
Copy link
Contributor Author

@DSchau DSchau left a comment

Choose a reason for hiding this comment

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

Think I ironed out any of the issues here. 👀 appreciated.

@@ -5,10 +5,10 @@ const syspath = require(`path`)

let numCopied = 0

const debouncedQuit = _.debounce(() => {
const quit = () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No need for debounce anymore. We know it's done when .on('ready') fires.

].concat(
packages.map(p => new RegExp(`${p}[\\/\\\\]src[\\/\\\\]`, `i`))
)
const watchers = packages.map(p => syspath.join(root, `/packages/`, p))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Set up an array of packages to watch, rather than iterating with a .forEach (which is kinda janky, and .on('ready') will fire for every package.

})
.on(`all`, (event, path) => {
if (event === `change` || event === `add`) {
const name = syspath.basename(syspath.dirname(path.split(`packages/`).pop()))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A little janky, but we need to infer the name from the full watched file path.

@DSchau
Copy link
Contributor Author

DSchau commented Sep 26, 2018

e2e tests are failing on /bin/sh: 1: gatsby: Permission denied, which is unrelated to this PR. I can merge upstream/master in to try again, one sec.

Tests are passing--although I think that was more luck than anything else. The e2e tests don't use this version of gatsby-dev-cli, they use the latest available.

@DSchau DSchau changed the title fix: increase debounce threshold in CI environments fix(gatsby-dev-cli): increase debounce threshold in CI environments Sep 27, 2018
Copy link
Contributor

@pieh pieh left a comment

Choose a reason for hiding this comment

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

Thanks @DSchau!

@pieh pieh merged commit 576f78a into gatsbyjs:master Sep 28, 2018
lipis added a commit to lipis/gatsby that referenced this pull request Sep 28, 2018
* 'master' of github.com:gatsbyjs/gatsby:
  chore(release): Publish
  fix: add missing html and body attributes from ssr apis to develop mode (gatsbyjs#8594)
  chore(www): bump gatsby version (gatsbyjs#8614)
  chore: upgrade Gatsby Version in Gatsbygram Readme (gatsbyjs#8604)
  fix(gatsby-dev-cli): wait for files to be copied before exiting (gatsbyjs#8387)
  fix: add missing GatsbyImageProps to TS defs (gatsbyjs#8606)
  chore: forgot frontmatter date change (gatsbyjs#8601)
  Add Hasura GraphQL engine example under third party (gatsbyjs#8584)
  blog: update incorrect post date (gatsbyjs#8600)
  Add gatsby-mdx-starter to the list of starters (gatsbyjs#8547)
  Draft graphiql doc (gatsbyjs#8599)
  Added redirect (gatsbyjs#8528)
  feat: provide fragments without gatsby-image (gatsbyjs#8459)
  updated CODEOWNERS (gatsbyjs#8591)
  Updates to sidebar (gatsbyjs#8539)
@DSchau DSchau deleted the gatsby-dev-cli/tweaks branch October 2, 2018 15:40
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.

[ci]: gatsby-dev-cli in CircleCI sometimes copies over 0 files
3 participants