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 development crasher on file deletion #2546

Merged
merged 5 commits into from
Oct 20, 2017

Conversation

mickeyreiss
Copy link
Contributor

Posting 77405d7 as the changes were helpful for my investigation but should not be merged.

See 9bd26ac for a full explanation.

Fixes #2542.

cc/ @KyleAMathews

@mickeyreiss
Copy link
Contributor Author

I was not sure what testing is typically done in this project. I verified that redux updates as expected and I am going to wait for CI to see whether any tests need to be updated.

console.warn(`parsing file ${file}`);
let text;
try {
text = await fs.readFile(file, `utf8`)
Copy link
Contributor Author

@mickeyreiss mickeyreiss Oct 20, 2017

Choose a reason for hiding this comment

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

Although this change is part of the throwaway commit, I thought I'd call this out. I couldn't reproduce the issue mentioned in the TODO. Seems like the conversion to async io "just works."

Previously, gatsby develop would crash upon deleting a page file. This
was happening due to an failed read of a non-existent file,
whose name was read from stale state.

The root cause was that `DELETE_PAGE` action's component reducer did not
remove the state data added by the complementary `CREATE_PAGE` reducer.

This change removes the appropriate component state on `DELETE_PAGE`
events.
@gatsbybot
Copy link
Collaborator

Deploy preview ready!

Built with commit 9bd26ac9f8496f1845d1afdc725b71d9af3b728a

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

@gatsbybot
Copy link
Collaborator

gatsbybot commented Oct 20, 2017

Deploy preview ready!

Built with commit ef94550

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

@@ -79,6 +79,7 @@ class Runner {
// FIXME: this should all use gatsby's configuration to determine parsable
// files (and how to parse them)
let files = glob.sync(`${this.fragmentsDir}/**/*.+(t|j)s?(x)`)
console.warn(files)
Copy link
Contributor

Choose a reason for hiding this comment

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

These are for debugging right?

@KyleAMathews
Copy link
Contributor

Played with this some more and super nice! Nice fix! Cleaning up edge bugs like this really are what makes the UX of a tool shine vs. feeling kinda crappy all the time.

Did a bit more work as well to fix returning to the development 404 page after the file was deleted as that wasn't handled correctly either.

Thanks for diving in and figuring things out and fixing the problem!

@KyleAMathews KyleAMathews merged commit 31f635d into gatsbyjs:master Oct 20, 2017
@@ -19,7 +19,7 @@
"gatsby-remark-images": "latest",
"gatsby-remark-katex": "latest",
"gatsby-remark-prismjs": "latest",
"gatsby-remark-responsive-iframe": "latest",
"gatsby-remark-responsive-iframe": "^1.4.9",
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this change related to the issue, or is it something else?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, I just ran yarn upgrade in this example site before using it to test your PR

@jlengstorf
Copy link
Contributor

Hiya @mickeyreiss! 👋

This is definitely late, but on behalf of the entire Gatsby community, I wanted to say thank you for being here.

Gatsby is built by awesome people like you. Let us say “thanks” in two ways:

  1. We’d like to send you some Gatsby swag. As a token of our appreciation, you can go to the Gatsby Swag Store and log in with your GitHub account to get a coupon code good for one free piece of swag. (We’ve got t-shirts and hats, plus some socks that are really razzing our berries right now.)
  2. If you’re not already part of it, we just invited you to join the Gatsby organization on GitHub. This will add you to our team of maintainers. You’ll receive an email shortly asking you to confirm. By joining the team, you’ll be able to label issues, review pull requests, and merge approved pull requests.

If you have questions, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’.

Thanks again! 💪💜

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.

5 participants