3

Yesterday and during many months everything worked fine when adding a blogpost via Contentful that triggered a build hook on Netlify. Today a new Blogg post add and build hook via Netlify does not work. When locally running gatsby develop or gatsby build everything works and the new blogpost is there.

Here is the error on Netlify: error "gatsby-node.js" threw an error while running the createPages lifecycle: 7:19:16 PM: Reducers may not dispatch actions:

enter image description here

  • Have tried "clearing cache and deploy site" button via Netlify
  • Have tried gatsby clean, npm install and pushing a triggered deploy also via GitHub

Unsure how to confirm cache is cleaned and what to try next. Any ideas?

Create pages:

const Promise = require('bluebird');
const path = require('path');

exports.createSchemaCustomization = ({ actions }) => {
  const { createTypes } = actions;
  const typeDefs = `
    type ContentfulHeroBanner implements Node {
      headerLeft: String
      headerCenter: String
      headerRight: String
    }
  `;
  createTypes(typeDefs);
};

exports.createPages = ({ graphql, actions }) => {
  const { createPage } = actions;

  return new Promise((resolve, reject) => {
    const blogPost = path.resolve('./src/templates/blog-post.js');
    resolve(
      graphql(
        `
          {
            allContentfulBlogPost {
              edges {
                node {
                  title
                  slug
                }
              }
            }
          }
        `
      ).then(result => {
        if (result.errors) {
          console.log(result.errors);
          reject(result.errors);
        }

        const posts = result.data.allContentfulBlogPost.edges;
        posts.forEach((post, index) => {
          createPage({
            path: `/blog/${post.node.slug}/`,
            component: blogPost,
            context: {
              slug: post.node.slug,
            },
          });
        });
      })
    );
  });
};
Patrik Rikama-Hinnenberg
  • 1,362
  • 1
  • 16
  • 27

1 Answers1

3

I managed to solve the problem. As I just tested removing the yarn.lock file without believing it would help. But after pushing this delete yarn.lock commit to master it triggered my build and this build Git repo without yarn.lock forced Netlify to rely on Installing NPM modules in the build and forgetting about Yarn.

This helped: https://community.netlify.com/t/support-guide-debugging-netlify-site-builds/142

Something mysterious regarding cache.

Patrik Rikama-Hinnenberg
  • 1,362
  • 1
  • 16
  • 27
  • 2
    I had a very similar situation and same build error except my gatsby repo did not include a yarn.lock file however it did contain a package-lock.json. Pushed a delete package-lock.json commit and the triggered Netlify build succeeded. Thank you. – Rich Tillis Jul 02 '20 at 21:37