-
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
[gatsby-plugin-sharp] Requires incorrect gatsby module in mono-repo #9984
Labels
type: bug
An issue or pull request relating to a bug in Gatsby
Comments
martin-css
added a commit
to martin-css/gatsby
that referenced
this issue
Nov 16, 2018
martin-css
added a commit
to martin-css/gatsby
that referenced
this issue
Nov 16, 2018
martin-css
changed the title
[gatsby-plugin-sharp] Bad Require Statement
[gatsby-plugin-sharp] Requires incorrect gatsby module in mono-repo
Nov 16, 2018
jgierer12
added
the
type: bug
An issue or pull request relating to a bug in Gatsby
label
Nov 18, 2018
pieh
pushed a commit
that referenced
this issue
Nov 21, 2018
…odule location. (#9986) The gatsby module resolve by require might not be the gatsby module that is executing. This can occur in mono-repo configurations. This will prevent the Redux store from receiving the job actions and the bootstrap process will complete without waiting for all images to be processed. This can cause the build to finish without all images being generated. Fixes #9984.
gpetrioli
pushed a commit
to gpetrioli/gatsby
that referenced
this issue
Jan 22, 2019
…odule location. (gatsbyjs#9986) The gatsby module resolve by require might not be the gatsby module that is executing. This can occur in mono-repo configurations. This will prevent the Redux store from receiving the job actions and the bootstrap process will complete without waiting for all images to be processed. This can cause the build to finish without all images being generated. Fixes gatsbyjs#9984.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
We run Gatsby inside a Docker container to build our web site. Recently we had added a fair number of images and noticed a strange issue where our automed e2e test was failing due to images not being found (404 error). Investigation of the build confirmed that the relevant folders has been generated in
public/static
but were empty.This was strange because it worked when being built locally on a developer and all images were produced. However, when running on our CI server, this was failing to produce all the images.
Given that the build was happening in a Docker container we assumed this must be some sort of race condition that occurs depending on the physical hardware used. Investigation confirmed that the CI server was taking longer to process each images and hence the overall build was completed before all images had been created.
This was strange as I was aware that the bootstrap process was meant to wait until all outstanding jobs were completed.
After some debugging, I found the root of the problem.
gatsby-plugin-sharp
acquires the bound action creators via this line:We run Gatsby iniside a monorepo. The plugin is correctly sending the
CREATE_JOB
andEND_JOB
actions but these were going to a totally different Redux store due to the way Yarn had hoisted the dependencies! The require will find the "closest"gatsby
which might not be thegatsby
module executing.Hence the correct store was never receiving the actions and the code in the bootstrap process to check for active jobs would pass even though the plugin was still working.
Corrective Action
gatsby-plugin-sharp
should use theactions
that are passed to thegatsby-node
API file. This will ensure the plugin is always referring to the correct store.I will submit a pull request with this change. I've mainly created this issue for reference purposes in case it helps anyone else.
Other considerations
I've not had time to check but any other plugins that pull out the
boundActionCreators
fromrequire('gatsby/dist/redux/actions')
would also suffer from this bug of referencing the wrong Redux store which could lead to all sorts of weird behaviour.The text was updated successfully, but these errors were encountered: