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

Most upvoted comments

Here it is, it might save you 4h of debugging:

Make sure the siteUrl in your gatsby-config.js is correct. Mine was missing the http:// and for some misterious reason I had this error output.

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 just released gatsby@2.23.18 that should fix the issue

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:

"gatsby": "2.23.17",
"gatsby-cli": "2.12.54",

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:

"gatsby": "2.23.17",
"gatsby-cli": "2.12.54",

However, locally I can finish build with this combination. But once it is running on the CI I receive this:

/home/runner/work/collect-frontend/collect-frontend/node_modules/yoga-layout-prebuilt/yoga-layout/build/Release/nbind.js:53
        throw ex;
        ^

RangeError: Maximum call stack size exceeded

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

"resolutions": {
  "babel-plugin-remove-graphql-queries": "2.9.9"
},

Either using yarn or choosing to install the npm resolution piece. This works both dev and build.

With:

  • gatsby v2.23.17
  • gatsby-plugin-offline v3.2.16
  • gatsby-cli v2.12.56

dev mode works 🚀

but building errors:

$ yarn build
yarn run v1.22.4
$ gatsby clean && gatsby build
info Deleting .cache, public
info Successfully deleted directories
success open and validate gatsby-configs - 0.036s
success load plugins - 0.947s
success onPreInit - 0.010s
success delete html and css files from previous builds - 0.010s
success initialize cache - 0.007s
success copy gatsby files - 0.054s
success onPreBootstrap - 0.009s
success createSchemaCustomization - 0.044s
success source and transform nodes - 0.182s
success building schema - 0.273s

 ERROR #11321  PLUGIN

"gatsby-plugin-offline" threw an error while running the createPages lifecycle:

Reducers may not dispatch actions.



  Error: Reducers may not dispatch actions.

  - redux.js:214 dispatch
    [vermehrung]/[redux]/lib/redux.js:214:13

  - index.js:67
    [vermehrung]/[gatsby]/dist/redux/index.js:67:88

  - index.js:14 Object.dispatch
    [vermehrung]/[redux-thunk]/lib/index.js:14:16

  - index.js:45 dispatch
    [vermehrung]/[gatsby-cli]/lib/reporter/redux/index.js:45:9

  - redux.js:483 Object.createLog
    [vermehrung]/[redux]/lib/redux.js:483:12

  - reporter.js:168 Reporter.warn
    [vermehrung]/[gatsby-cli]/lib/reporter/reporter.js:168:41

  - patch-console.js:22 Object.console.warn
    [vermehrung]/[gatsby-cli]/lib/reporter/patch-console.js:22:14

  - utils.js:449 Object.warn
    [vermehrung]/[xstate]/lib/utils.js:449:26

  - StateNode.js:1313
    [vermehrung]/[xstate]/lib/StateNode.js:1313:29

  - Array.map

  - StateNode.js:1311 StateNode.formatTransitions
    [vermehrung]/[xstate]/lib/StateNode.js:1311:18

  - StateNode.js:321 StateNode.get [as transitions]
    [vermehrung]/[xstate]/lib/StateNode.js:321:51

  - StateNode.js:296 StateNode.get [as on]
    [vermehrung]/[xstate]/lib/StateNode.js:296:36

  - StateNode.js:230
    [vermehrung]/[xstate]/lib/StateNode.js:230:93

  - Array.forEach

  - StateNode.js:230 StateNode._init
    [vermehrung]/[xstate]/lib/StateNode.js:230:45


failed createPages - 0.082s
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

For me it was changing siteMetaData to siteMetadata 😃

Same Issue here, I just delete everything “cache”, “node_modules”, “public”, “yarn.lock”, make a fresh install, update my gatsby-cli to the latest version. image

Just doing what @alexjsdev said in a comment before yarn add gatsby-cli@2.12.54 this fix the issue for me. Thanks to @alexjsdev

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 opened #25483 to adjust xstate code, but we can’t fix older releases, those will need to rely on yarn resolutions or npm install --save-exact tricks to not install xstate@4.11.0 and keep it on lower version (4.10.0 for example)

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

Screenshot 2020-07-02 21 32 23

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.