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

Strange bug with deletePage and createPage #12480

Closed
kg55kmr opened this issue Mar 11, 2019 · 4 comments
Closed

Strange bug with deletePage and createPage #12480

kg55kmr opened this issue Mar 11, 2019 · 4 comments
Labels
status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. type: bug An issue or pull request relating to a bug in Gatsby
Projects

Comments

@kg55kmr
Copy link

kg55kmr commented Mar 11, 2019

Description

After modifing placeholder file in /src/data/ index page is removed and server returns 404

Steps to reproduce

Repository with code

Expected result

Index page must not be deleted.

Actual result

After hot reloading index page is removed and server returns 404

Environment

System:
OS: Windows 7
CPU: (2) ia32 AMD Athlon(tm) II X2 240 Processor
Binaries:
npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
npmPackages:
gatsby: ^2.1.28 => 2.1.28
gatsby-source-filesystem: ^2.0.23 => 2.0.23

@pieh pieh added the type: bug An issue or pull request relating to a bug in Gatsby label Mar 11, 2019
@pieh
Copy link
Contributor

pieh commented Mar 11, 2019

I defenitely can reproduce. Investigating right now

@pieh pieh added the status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. label Mar 11, 2019
@pieh
Copy link
Contributor

pieh commented Mar 11, 2019

Ok, so here are my findings:

this deletes pages:

// Delete pages that weren't updated when running createPages.
Array.from(store.getState().pages.values()).forEach(page => {
if (
!_.includes(statefulPlugins, page.pluginCreatorId) &&
page.updatedAt < timestamp &&
page.path !== `/404.html`
) {
deleteComponentsDependencies([page.path])
deletePage(page)
}
})

because when you re-create page in onCreatePage hook, page is taken over from gatsby-plugin-page-creator (which is stateful plugin) by yours gatsby-node which is not stateful.

I think we would need to adjust

// Link page to its plugin.
action.payload.pluginCreator___NODE = action.plugin.id
action.payload.pluginCreatorId = action.plugin.id

so page doesn't change pluginCreator (if it's already set)

@kg55kmr
Copy link
Author

kg55kmr commented Mar 12, 2019

gatsby-mdx not working correctly after hot reloading too. So hmr only working correctly with pages that was created programmatically and they are not stateful.

@kg55kmr
Copy link
Author

kg55kmr commented Mar 21, 2019

Bug is fixed with #12671

@kg55kmr kg55kmr closed this as completed Mar 21, 2019
OSS Roadmap automation moved this from To do to Done Mar 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. type: bug An issue or pull request relating to a bug in Gatsby
Projects
No open projects
OSS Roadmap
  
Done
Development

No branches or pull requests

2 participants