gatsby: Error: Reducers may not dispatch actions
Description
After either develop
or build
is run, the following error message is displayed:
SHOW ERROR MSG
gatsby develop
ERROR
UNHANDLED REJECTION Reducers may not dispatch actions.
Error: Reducers may not dispatch actions.
redux.js:213 dispatch [demo6_gatsby]/[redux]/lib/redux.js:213:13
index.js:58 [demo6_gatsby]/[gatsby]/dist/redux/index.js:58:88
index.js:14 Object.dispatch [demo6_gatsby]/[redux-thunk]/lib/index.js:14:16
index.js:47 dispatch [demo6_gatsby]/[gatsby-cli]/lib/reporter/redux/index.js:47:11
redux.js:481 Object.createLog [demo6_gatsby]/[redux]/lib/redux.js:481:12
index.js:67 Object.log [demo6_gatsby]/[gatsby-cli]/lib/reporter/index.js:67:53
index.js:459 Object.console.log [demo6_gatsby]/[gatsby-cli]/lib/reporter/index.js:459:37
config.js:20 module.exports [demo6_gatsby]/[gatsby]/dist/redux/reducers/config.js:20:19
redux.js:464 combination [demo6_gatsby]/[redux]/lib/redux.js:464:29
redux.js:218 dispatch [demo6_gatsby]/[redux]/lib/redux.js:218:22
index.js:58 [demo6_gatsby]/[gatsby]/dist/redux/index.js:58:88
index.js:14 Object.dispatch [demo6_gatsby]/[redux-thunk]/lib/index.js:14:16
index.js:168 module.exports [demo6_gatsby]/[gatsby]/dist/bootstrap/index.js:168:9
develop.js:419 async module.exports [demo6_gatsby]/[gatsby]/dist/commands/develop.js:419:7
not finished open and validate gatsby-configs - 0.161s error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Closest issue is https://github.com/reduxjs/redux-thunk/issues/122
but not sure it applies to my project
Steps to reproduce
gatsby develop
Expected result
Site should be built
Actual result
Error message is displayed
Environment
SHOW CONTENT
System: OS: Windows 10 10.0.18363 CPU: (8) x64 Intel® Core™ i7 CPU @ 3.50GHz Binaries: Node: 13.0.1 - C:\Program Files\nodejs\node.EXE Yarn: 1.19.2 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 6.12.0 - C:\Program Files\nodejs\npm.CMD Languages: Python: 2.7.13 Browsers: Edge: 44.18362.449.0 npmPackages: gatsby: ^2.18.3 => 2.18.11 gatsby-background-image: ^0.9.7 => 0.9.11 gatsby-image: ^2.2.33 => 2.2.36 gatsby-plugin-catch-links: ^2.1.18 => 2.1.21 gatsby-plugin-facebook-pixel: ^1.0.3 => 1.0.3 gatsby-plugin-google-analytics: ^2.1.29 => 2.1.31 gatsby-plugin-manifest: ^2.2.29 => 2.2.33 gatsby-plugin-offline: ^3.0.23 => 3.0.29 gatsby-plugin-react-helmet: ^3.1.15 => 3.1.18 gatsby-plugin-remove-console: ^0.0.2 => 0.0.2 gatsby-plugin-robots-txt: ^1.5.0 => 1.5.0 gatsby-plugin-sass: ^2.1.24 => 2.1.26 gatsby-plugin-sharp: ^2.3.3 => 2.3.7 gatsby-plugin-sitemap: ^2.2.22 => 2.2.24 gatsby-source-filesystem: ^2.1.38 => 2.1.42 gatsby-transformer-sharp: ^2.3.5 => 2.3.9
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 3
- Comments: 48 (8 by maintainers)
Commits related to this issue
- fix: Reducers may not dispatch actions https://github.com/gatsbyjs/gatsby/issues/20082#issuecomment-568292986 — committed to antvis/G2 by afc163 5 years ago
- fix: Reducers may not dispatch actions https://github.com/gatsbyjs/gatsby/issues/20082#issuecomment-568292986 — committed to antvis/G2 by afc163 5 years ago
Here it is, it might save you 4h of debugging:
Make sure the
siteUrl
in yourgatsby-config.js
is correct. Mine was missing thehttp://
and for some misterious reason I had this error output.The issue is tracked here: https://github.com/gatsbyjs/gatsby/issues/25478 and will be solved by https://github.com/gatsbyjs/gatsby/pull/25483
FWIW, in debugging our builds we’ve found that any plugin (including our local ones) that use the
createPages
API with the latest gatsby-cli version, error with this same error. In other words, I don’t think this is specific to any plugin.Separately it looks like there was an issue for dev builds when core-js was upgraded to v3 but it looks like that was reverted in the latest gatsby releases greater than patch 15.
@barbalex you should try downgrading your gatsby-cli now that you’ve updated to the latest gatsby version that fixes the other core-js issue. It should fix your issue and allow you to build for now. just run
yarn add gatsby-cli@2.12.54
We just had the same issue. After downgrading gatsby-cli to version 2.12.54 this error is no longer raised.
FYI it’s fixed: https://github.com/gatsbyjs/gatsby/issues/25478#issuecomment-653207216
I am suddenly getting this when updating gatsby from v2.20.36 to v2.13.16.
I have absolutely no idea what could be wrong - after all: gastby-config.js has not changed. Only the gatsby version.
I had the exact same issue. It’s unrelated to redux but it’s related to gatsby-config.js not being configured properly
@hiramoto having these version fixed this:
once You update, You will get the next one
Why is this issue closed? 😃
For me it seems to be an infinite amount of bugs, using the following versions seemingly fixes it:
However, locally I can finish build with this combination. But once it is running on the CI I receive this:
any idea why?
EDIT: It is github actions on an ubuntu-latest container, running NPM.
The fix right now that works with the latest gatsby + you do not need to copy any other package version etc is:
In your
package.json
Either using
yarn
or choosing to install the npm resolution piece. This works both dev and build.With:
dev mode works 🚀
but building errors:
For me it was changing
siteMetaData
tositeMetadata
😃I had exactly the same issue. I did not have gastby-cli installed in my project.
I just installed it and it’s building correctly in local and in circle-ci.
FYI to anyone who can’t upgrade:
npm install --save-exact xstate@4.10.0
https://github.com/gatsbyjs/gatsby/issues/25478#issuecomment-653181943
I’ve tested on another project, has updated everything, except latest gatsby 2.23.15, and build was working. As soon as I updated gatsby to 2.23.15, build has broken. I’ve compared yarn.lock
post your gatsby-config
The real error message wasn’t being displayed on the console for some reason. I attached the debugger (using WebStorm) and added a breakpoint on that Exception and found the error was about a syntax issue, unrelated to Redux.