Build exceeded maximum allowed runtime - Gatsby 4.16.0

I’ve encountered a deployment runtime problem after upgrading gatsbyJs from 4.15.2 to 4.16.0. Whenever I try to deploy the site, it gets stuck at Writing page-data.json files to public directory, then it times out after half an hour with a message “Build exceeded maximum allowed runtime”. Can someone at Netlify help identify what exactly is causing this issue? I’ve temporarily rolled back to the previous commit until I can find a fix. Deploy log is attached below:

Site Url: tng.netlify.app

Deploy log:

10:55:02 AM: Build ready to start
10:55:04 AM: build-image version: a49edbc55fc722f80f6b85963a5060f8d043a844 (focal)
10:55:04 AM: build-image tag: v4.8.1
10:55:04 AM: buildbot version: f89dd42aa70d76d1da992dc3fa004a4c745208bc
10:55:04 AM: Fetching cached dependencies
10:55:08 AM: Finished downloading cache in 3.535679066s
10:55:08 AM: Starting to extract cache
10:55:23 AM: Finished extracting cache in 14.762715413s
10:55:23 AM: Finished fetching cache in 18.339454802s
10:55:23 AM: Starting to prepare the repo for build
10:55:23 AM: Preparing Git Reference refs/heads/main
10:55:24 AM: Parsing package.json dependencies
10:55:25 AM: Starting build script
10:55:25 AM: Installing dependencies
10:55:25 AM: Python version set to 2.7
10:55:25 AM: Started restoring cached node version
10:55:26 AM: Finished restoring cached node version
10:55:27 AM: v16.15.0 is already installed.
10:55:27 AM: Now using node v16.15.0 (npm v8.5.5)
10:55:27 AM: Started restoring cached build plugins
10:55:27 AM: Finished restoring cached build plugins
10:55:27 AM: Attempting ruby version 2.7.2, read from environment
10:55:28 AM: Using ruby version 2.7.2
10:55:28 AM: Using PHP version 8.0
10:55:29 AM: No npm workspaces detected
10:55:29 AM: Started restoring cached node modules
10:55:29 AM: Finished restoring cached node modules
10:55:29 AM: Installing NPM modules using NPM version 8.5.5
10:55:43 AM: added 2 packages, removed 1 package, changed 101 packages, and audited 2051 packages in 14s
10:55:43 AM: 307 packages are looking for funding
10:55:43 AM:   run `npm fund` for details
10:55:43 AM: 45 vulnerabilities (8 moderate, 37 high)
10:55:43 AM: To address issues that do not require attention, run:
10:55:43 AM:   npm audit fix
10:55:43 AM: To address all issues (including breaking changes), run:
10:55:43 AM:   npm audit fix --force
10:55:43 AM: Run `npm audit` for details.
10:55:43 AM: NPM modules installed
10:55:44 AM: Started restoring cached go cache
10:55:44 AM: Finished restoring cached go cache
10:55:44 AM: Installing Go version 1.16.5 (requested 1.16.5)
10:55:49 AM: unset GOOS;
10:55:49 AM: unset GOARCH;
10:55:49 AM: export GOROOT='/opt/buildhome/.gimme/versions/go1.16.5.linux.amd64';
10:55:49 AM: export PATH="/opt/buildhome/.gimme/versions/go1.16.5.linux.amd64/bin:${PATH}";
10:55:49 AM: go version >&2;
10:55:49 AM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.16.5.linux.amd64.env"
10:55:49 AM: go version go1.16.5 linux/amd64
10:55:49 AM: Installing missing commands
10:55:49 AM: Verify run directory
10:55:50 AM: ​
10:55:50 AM: ────────────────────────────────────────────────────────────────
10:55:50 AM:   Netlify Build                                                 
10:55:50 AM: ────────────────────────────────────────────────────────────────
10:55:50 AM: ​
10:55:50 AM: ❯ Version
10:55:50 AM:   @netlify/build 27.1.5
10:55:50 AM: ​
10:55:50 AM: ❯ Flags
10:55:50 AM:   baseRelDir: true
10:55:50 AM:   buildId: 62acbff6fb5b4d09067ba42b
10:55:50 AM:   deployId: 62acbff6fb5b4d09067ba42d
10:55:50 AM: ​
10:55:50 AM: ❯ Current directory
10:55:50 AM:   /opt/build/repo
10:55:50 AM: ​
10:55:50 AM: ❯ Config file
10:55:50 AM:   No config file was defined: using default values.
10:55:50 AM: ​
10:55:50 AM: ❯ Context
10:55:50 AM:   production
10:55:50 AM: ​
10:55:50 AM: ❯ Loading plugins
10:55:50 AM:    - @netlify/plugin-gatsby@3.2.1 from Netlify app
10:55:52 AM: ​
10:55:52 AM: ────────────────────────────────────────────────────────────────
10:55:52 AM:   1. @netlify/plugin-gatsby (onPreBuild event)                  
10:55:52 AM: ────────────────────────────────────────────────────────────────
10:55:52 AM: ​
10:55:55 AM: Found a Gatsby cache. We’re about to go FAST. ⚡️
10:55:55 AM: ​
10:55:55 AM: (@netlify/plugin-gatsby onPreBuild completed in 2.8s)
10:55:55 AM: ​
10:55:55 AM: ────────────────────────────────────────────────────────────────
10:55:55 AM:   2. Build command from Netlify app                             
10:55:55 AM: ────────────────────────────────────────────────────────────────
10:55:55 AM: ​
10:55:55 AM: $ npm run build
10:55:55 AM: > gatsby-starter-default@0.1.0 build
10:55:55 AM: > gatsby build
10:55:58 AM: success compile gatsby files - 0.802s
10:55:58 AM: success load gatsby config - 0.058s
10:55:59 AM: success load plugins - 1.193s
10:55:59 AM: success onPreInit - 0.007s
10:55:59 AM: success delete worker cache from previous builds - 0.001s
10:55:59 AM: info One or more of your plugins have changed since the last time you ran Gatsby. As
10:55:59 AM: a precaution, we're deleting your site's cache to ensure there's no stale data.
success initialize cache - 0.088s
10:55:59 AM: success copy gatsby files - 0.174s
10:56:00 AM: success Compiling Gatsby Functions - 0.201s
10:56:00 AM: success onPreBootstrap - 0.220s
10:56:00 AM: success createSchemaCustomization - 0.115s
10:56:01 AM: success Contentful: Sync all items - 0.186s - 66/66 355.10/s
10:56:01 AM: success Contentful: Fetch data - 0.476s
10:56:01 AM: info Contentful: 1 new entries
10:56:01 AM: info Contentful: 24 updated entries
10:56:01 AM: info Contentful: 0 deleted entries
10:56:01 AM: info Contentful: 0 cached entries
10:56:01 AM: info Contentful: 21 new assets
10:56:01 AM: info Contentful: 20 updated assets
10:56:01 AM: info Contentful: 0 cached assets
10:56:01 AM: info Contentful: 0 deleted assets
10:56:01 AM: info Creating 4 Contentful News nodes
10:56:01 AM: info Creating 4 Contentful Program nodes
10:56:02 AM: info Creating 1 Contentful Members Page nodes
10:56:02 AM: info Creating 4 Contentful Seasonal nodes
10:56:02 AM: info Creating 1 Contentful Hero Video nodes
10:56:02 AM: info Creating 4 Contentful Job nodes
10:56:02 AM: info Creating 1 Contentful Admission Page nodes
10:56:03 AM: info Creating 6 Contentful SEO nodes
10:56:03 AM: info Creating 41 Contentful asset nodes
10:56:04 AM: success Contentful: Create nodes - 2.807s
10:56:04 AM: success Contentful: Process data - 2.812s
10:56:04 AM: success Checking for changed pages - 0.000s
10:56:04 AM: success source and transform nodes - 3.999s
10:56:05 AM: info Writing GraphQL type definitions to /opt/build/repo/.cache/schema.gql
10:56:06 AM: success building schema - 2.116s
10:56:06 AM: success createPages - 0.203s
10:56:07 AM: success createPagesStatefully - 0.602s
10:56:07 AM: info Total nodes: 363, SitePage nodes: 47 (use --verbose for breakdown)
10:56:07 AM: success Checking for changed pages - 0.000s
10:56:07 AM: success Cleaning up stale page-data - 0.004s
10:56:07 AM: success onPreExtractQueries - 0.000s
10:56:15 AM: success extract queries from components - 8.002s
10:56:15 AM: success write out redirect data - 0.408s
10:56:16 AM: success Build manifest and related icons - 0.717s
10:56:16 AM: success onPostBootstrap - 0.720s
10:56:16 AM: info bootstrap finished - 20.922s
10:56:16 AM: success write out requires - 0.274s
10:57:08 AM: success Building production JavaScript and CSS bundles - 51.990s
10:57:45 AM: success Building HTML renderer - 36.783s
10:57:45 AM: success Execute page configs - 0.052s
10:57:45 AM: success Caching Webpack compilations - 0.001s
10:57:52 AM: success run queries in workers - 6.967s - 48/48 6.89/s
10:58:32 AM: success Running gatsby-plugin-sharp.IMAGE_PROCESSING jobs - 138.583s - 43/43 0.31/s
10:58:32 AM: success Merge worker state - 0.003s
10:58:32 AM: success Rewriting compilation hashes - 0.001s
10:58:32 AM: success Writing page-data.json files to public directory - 0.024s - 47/47 1934.71/s
11:31:03 AM: Build exceeded maximum allowed runtime
11:31:11 AM: info deleted directory at /opt/build/repo/src/images/assets
11:31:11 AM: info deleted directory at /opt/build/repo/src/images/clients
11:31:11 AM: info deleted directory at /opt/build/repo/src/images/icons
11:31:11 AM: info deleted directory at /opt/build/repo/src/images/illustrations
11:31:11 AM: info deleted directory at /opt/build/repo/src/images/logos
11:31:11 AM: info deleted directory at /opt/build/repo/src/images/programs
11:31:11 AM: info deleted directory at /opt/build/repo/src/images
11:31:11 AM: info deleted file at /opt/build/repo/src/images/assets/deco.svg
11:31:11 AM: info deleted file at /opt/build/repo/src/images/assets/kids.png
11:31:11 AM: info deleted file at /opt/build/repo/src/images/assets/kids_at_school.jpg
11:31:11 AM: info deleted file at /opt/build/repo/src/images/assets/loading.gif
11:31:11 AM: info deleted file at /opt/build/repo/src/images/assets/tsukiji.jpg
11:31:11 AM: info deleted file at /opt/build/repo/src/images/assets/tsykishima.jpg
11:31:11 AM: info deleted file at /opt/build/repo/src/images/logo.png
11:31:11 AM: info deleted file at /opt/build/repo/src/images/clients/1.png
11:31:11 AM: info deleted file at /opt/build/repo/src/images/clients/2.png
11:31:11 AM: info deleted file at /opt/build/repo/src/images/icons/pin.svg
11:31:11 AM: info deleted file at /opt/build/repo/src/images/icons/play.svg
11:31:11 AM: info deleted file at /opt/build/repo/src/images/icons/polygon.svg
11:31:11 AM: info deleted file at /opt/build/repo/src/images/icons/quotation.svg
11:31:11 AM: info deleted file at /opt/build/repo/src/images/illustrations/book.png
11:31:11 AM: info deleted file at /opt/build/repo/src/images/illustrations/calculator.png
11:31:11 AM: info deleted file at /opt/build/repo/src/images/illustrations/calendar.png
11:31:11 AM: info deleted file at /opt/build/repo/src/images/illustrations/creativity.png
11:31:11 AM: info deleted file at /opt/build/repo/src/images/illustrations/ebook.png
11:31:11 AM: info deleted file at /opt/build/repo/src/images/illustrations/grades.png
11:31:11 AM: info deleted file at /opt/build/repo/src/images/illustrations/graduation.png
11:31:11 AM: info deleted file at /opt/build/repo/src/images/illustrations/lab.png
11:31:11 AM: info deleted file at /opt/build/repo/src/images/illustrations/mixedage.png
11:31:11 AM: info deleted file at /opt/build/repo/src/images/illustrations/note.png
11:31:11 AM: info deleted file at /opt/build/repo/src/images/illustrations/notes.png
11:31:11 AM: info deleted file at /opt/build/repo/src/images/illustrations/paint-palette.png
11:31:11 AM: info deleted file at /opt/build/repo/src/images/illustrations/sleep.png
11:31:11 AM: info deleted file at /opt/build/repo/src/images/illustrations/winner.png
11:31:11 AM: info deleted file at /opt/build/repo/src/images/logos/academy.svg
11:31:11 AM: info deleted file at /opt/build/repo/src/images/logos/haxlab.svg
11:31:11 AM: info deleted file at /opt/build/repo/src/images/logos/logo.svg
11:31:11 AM: info deleted file at /opt/build/repo/src/images/logos/logo2.svg
11:31:11 AM: info deleted file at /opt/build/repo/src/images/logos/tng.svg
11:31:11 AM: info deleted file at /opt/build/repo/src/images/programs/busybees.jpg
11:31:11 AM: info deleted file at /opt/build/repo/src/images/programs/littlepeople.jpg
11:31:11 AM: info deleted file at /opt/build/repo/src/images/programs/parenting.jpg
11:31:11 AM: info deleted file at /opt/build/repo/src/images/programs/saplings.jpg
11:31:11 AM: info deleted file at /opt/build/repo/src/images/programs/springkid.jpg
11:31:11 AM: info deleted file at /opt/build/repo/src/images/programs/summerkid.jpg
11:31:11 AM: info deleted file at /opt/build/repo/src/images/programs/winterkid.jpg

hi there, i am going to guess that your build time will get shorter once you have a complete build and we don’t need to download dependencies and have something in cache.

the default runtime is 15 minutes - if you add a credit card to your account so that we can bill for additional build minutes should they become necessary, we can increase your build time sufficiently so you can get a build going. let me know if you want me to do that!

I have the exact same issue going on, and i didn’t upgrade gatsby. I added one small dependency, made a few changes to components, and all of a sudden when I push to remote repo or trigger a build manually, it hangs and ultimately fails when writing page-data.json

Did you ever resolve this? It doesn’t seem like it would be an issue of increasing build minutes to fix this. My builds were only taking 2-3 minutes prior to this last commit.

Just curious if you figured anything out on this. I already submitted a new topic, still no response.

I’ve replied to your thread: