SSWConsulting / SSWConsulting/SSW.Rules

🐛 Gatsby Build - GitHub Actions Sometimes Runs Forever

Open
#1,709 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Type: Bug zzOld
Dominant language
TypeScript
Stars
26
Forks
17
Avg merge
14h 39m
Merged PRs (30d)
2

Description

Cc: @SSWRules

Hi team,

Describe the Bug

Creating a PBI to track the Gatsby Build in Github Actions that sometimes runs forever: https://github.com/gatsbyjs/gatsby/issues/38989

Expected Behavior

We want that that the build never fall into an infinite loop

Tasks
  • Investigate
  • Fix
More Information

I asked embedded GitHub Actions Copilot, and he suggested:

The failure in the job log indicates multiple issues, but the primary problems are:

  1. Deprecated API Usage:

    • The plugin gatsby-transformer-remark@3.2.0 uses the API unstable_shouldOnCreateNode, which is no longer valid. It suggests renaming it to shouldOnCreateNode.
  2. Query Performance:

    • Queries in src/pages/index.js and src/pages/orphaned.js are taking over 15 seconds, which is likely causing performance bottlenecks.
  3. Job Timeout:

    • The build action has timed out after 30 minutes, possibly due to the above inefficiencies or other issues not explicitly detailed in the log.
Solutions
1. Fix Deprecated API Usage

Update the gatsby-transformer-remark plugin configuration:

// gatsby-config.js or relevant plugin file
module.exports = {
  plugins: [
    {
      resolve: `gatsby-transformer-remark`,
      options: {
        // Ensure you're using the updated API
        shouldOnCreateNode: (node) => {
          // Update logic as per new API requirements
        },
      },
    },
  ],
};

Alternatively, update the plugin to the latest version if it supports the corrected API.

2. Optimize Queries

Review the GraphQL queries in src/pages/index.js and src/pages/orphaned.js. For example:

// If querying GraphQL in Gatsby
export const query = graphql`
  query OptimizedQuery {
    allMarkdownRemark(limit: 10, sort: { fields: [date], order: DESC }) {
      edges {
        node {
          id
          frontmatter {
            title
            date
          }
        }
      }
    }
  }
`;
// Break down complex queries into smaller ones if possible
3. Increase Timeout or Optimize Build

In the .github/workflows/build-deploy-production.yml, increase the job timeout or parallelize tasks:

jobs:
  build:
    timeout-minutes: 60 # Increase timeout if necessary
    steps:
      # Optimize steps or run in parallel
      - name: Build Step 1
        run: npm run build-part-1
      - name: Build Step 2
        run: npm run build-part-2
Next Steps
  • Update the gatsby-transformer-remark plugin to the latest version or correct the API usage.
  • Refactor the slow GraphQL queries in your pages.
  • Adjust the workflow YAML to prevent job timeouts by optimizing builds or increasing timeout limits.

Thanks!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Gatsby issue and the GitHub Actions job logs, then inspect .github/workflows/build-deploy-production.yml, gatsby-config.js, src/pages/index.js, and src/pages/orphaned.js. Determine which issue causes the build to run indefinitely and verify that the workflow completes reliably without a timeout.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, graphql, javascript
Domain
build-system, ci-cd, web-dev
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.