Nextjs SSG site deploy works through cli, but hangs in CI and dashboard trigger deployments

I’m trying to move over a website from Vercel to see if we can have the production deployment on the amazing Netlify platform, but I keep running into this strange issue. I appreciate any support.

Problem: Continuous deployments whenever I push to git and deployments triggered manually from the dashboard hang indefinitely.

Manual deployments through the cli command netlify deploy –build –prod work fine.

Stack: Nextjs SSG Site with Payload CMS and Neon Postgres DB.

Site: marn-web.netlify.app
Build logs:

Logs
5:38:49 PM: build-image version: bdde7508058f3bebb60be9fd276baa638423bce0 (noble)
5:38:49 PM: buildbot version: 6e7a6a2557e0a0eca440918037550266ac08c7be
5:38:49 PM: Fetching cached dependencies
5:38:50 PM: Failed to fetch cache, continuing with build
5:38:50 PM: Starting to prepare the repo for build
5:38:50 PM: No cached dependencies found. Cloning fresh repo
5:38:50 PM: git clone --filter=blob:none https://github.com/omaroubari/marn-web
5:38:50 PM: Preparing Git Reference refs/heads/main
5:38:54 PM: Starting to install dependencies
5:38:55 PM: Downloading and installing node v22.21.1…
5:38:55 PM: Downloading https://nodejs.org/dist/v22.21.1/node-v22.21.1-linux-x64.tar.xz…
5:38:56 PM: Computing checksum with sha256sum
5:38:56 PM: Checksums matched!
5:38:59 PM: Now using node v22.21.1 (npm v10.9.4)
5:38:59 PM: Enabling Node.js Corepack
5:38:59 PM: Started restoring cached build plugins
5:38:59 PM: Finished restoring cached build plugins
5:38:59 PM: Started restoring cached corepack dependencies
5:38:59 PM: Finished restoring cached corepack dependencies
5:38:59 PM: No pnpm workspaces detected
5:38:59 PM: Started restoring cached node modules
5:38:59 PM: Finished restoring cached node modules
5:38:59 PM: Installing npm packages using pnpm version 10.19.0
5:39:00 PM: Lockfile is up to date, resolution step is skipped
5:39:00 PM: Progress: resolved 1, reused 0, downloaded 0, added 0
5:39:00 PM: Packages: +1749
5:39:00 PM: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5:39:01 PM: Progress: resolved 1749, reused 0, downloaded 73, added 18
5:39:02 PM: Progress: resolved 1749, reused 0, downloaded 134, added 43
5:39:03 PM: Progress: resolved 1749, reused 0, downloaded 160, added 52
5:39:04 PM: Progress: resolved 1749, reused 0, downloaded 204, added 65
5:39:05 PM: Progress: resolved 1749, reused 0, downloaded 287, added 92
5:39:06 PM: Progress: resolved 1749, reused 0, downloaded 301, added 96
5:39:07 PM: Progress: resolved 1749, reused 0, downloaded 312, added 99
5:39:08 PM: Progress: resolved 1749, reused 0, downloaded 324, added 103
5:39:09 PM: Progress: resolved 1749, reused 0, downloaded 400, added 138
5:39:10 PM: Progress: resolved 1749, reused 0, downloaded 443, added 160
5:39:11 PM: Progress: resolved 1749, reused 0, downloaded 445, added 162
5:39:12 PM: Progress: resolved 1749, reused 0, downloaded 507, added 189
5:39:13 PM: Progress: resolved 1749, reused 0, downloaded 632, added 233
5:39:14 PM: Progress: resolved 1749, reused 0, downloaded 687, added 260
5:39:15 PM: Progress: resolved 1749, reused 0, downloaded 755, added 281
5:39:16 PM: Progress: resolved 1749, reused 0, downloaded 783, added 289
5:39:17 PM: Progress: resolved 1749, reused 0, downloaded 849, added 309
5:39:18 PM: Progress: resolved 1749, reused 0, downloaded 886, added 316
5:39:19 PM: Progress: resolved 1749, reused 0, downloaded 925, added 324
5:39:20 PM: Progress: resolved 1749, reused 0, downloaded 979, added 335
5:39:21 PM: Progress: resolved 1749, reused 0, downloaded 1010, added 341
5:39:22 PM: Progress: resolved 1749, reused 0, downloaded 1087, added 360
5:39:23 PM: Progress: resolved 1749, reused 0, downloaded 1163, added 376
5:39:24 PM: Progress: resolved 1749, reused 0, downloaded 1254, added 401
5:39:25 PM: Progress: resolved 1749, reused 0, downloaded 1415, added 450
5:39:26 PM: Progress: resolved 1749, reused 0, downloaded 1530, added 490
5:39:27 PM: Progress: resolved 1749, reused 0, downloaded 1672, added 538
5:39:28 PM: Progress: resolved 1749, reused 0, downloaded 1749, added 650
5:39:29 PM: Progress: resolved 1749, reused 0, downloaded 1749, added 689
5:39:30 PM: Progress: resolved 1749, reused 0, downloaded 1749, added 708
5:39:31 PM: Progress: resolved 1749, reused 0, downloaded 1749, added 746
5:39:32 PM: Progress: resolved 1749, reused 0, downloaded 1749, added 749
5:39:33 PM: Progress: resolved 1749, reused 0, downloaded 1749, added 756
5:39:34 PM: Progress: resolved 1749, reused 0, downloaded 1749, added 794
5:39:35 PM: Progress: resolved 1749, reused 0, downloaded 1749, added 899
5:39:36 PM: Progress: resolved 1749, reused 0, downloaded 1749, added 1007
5:39:37 PM: Progress: resolved 1749, reused 0, downloaded 1749, added 1088
5:39:38 PM: Progress: resolved 1749, reused 0, downloaded 1749, added 1204
5:39:39 PM: Progress: resolved 1749, reused 0, downloaded 1749, added 1419
5:39:40 PM: Progress: resolved 1749, reused 0, downloaded 1749, added 1538
5:39:41 PM: Progress: resolved 1749, reused 0, downloaded 1749, added 1543
5:39:42 PM: Progress: resolved 1749, reused 0, downloaded 1749, added 1704
5:39:42 PM: Progress: resolved 1749, reused 0, downloaded 1749, added 1749, done
5:39:44 PM: dependencies:
5:39:44 PM: + @ai-sdk/google 1.2.22
5:39:44 PM: + @ai-sdk/openai 1.3.24
5:39:44 PM: + @faceless-ui/window-info 3.0.1
5:39:44 PM: + @iconify/json 2.2.355
5:39:44 PM: + @iconify/tools 4.1.2
5:39:44 PM: + @iconify/utils 2.3.0
5:39:44 PM: + @next/bundle-analyzer 15.5.4
5:39:44 PM: + @next/env 15.5.4
5:39:44 PM: + @payloadcms/db-postgres 3.59.1
5:39:44 PM: + @payloadcms/db-vercel-postgres 3.59.1
5:39:44 PM: + @payloadcms/email-resend 3.59.1
5:39:44 PM: + @payloadcms/live-preview-react 3.59.1
5:39:44 PM: + @payloadcms/next 3.59.1
5:39:44 PM: + @payloadcms/payload-cloud 3.59.1
5:39:44 PM: + @payloadcms/plugin-form-builder 3.59.1
5:39:44 PM: + @payloadcms/plugin-nested-docs 3.59.1
5:39:44 PM: + @payloadcms/plugin-redirects 3.59.1
5:39:44 PM: + @payloadcms/plugin-search 3.59.1
5:39:44 PM: + @payloadcms/plugin-seo 3.59.1
5:39:44 PM: + @payloadcms/richtext-lexical 3.59.1
5:39:44 PM: + @payloadcms/storage-s3 3.59.1
5:39:44 PM: + @payloadcms/translations 3.59.1
5:39:44 PM: + @payloadcms/ui 3.59.1
5:39:44 PM: + @radix-ui/react-accordion 1.2.12
5:39:44 PM: + @radix-ui/react-checkbox 1.3.3
5:39:44 PM: + @radix-ui/react-dialog 1.1.15
5:39:44 PM: + @radix-ui/react-direction 1.1.1
5:39:44 PM: + @radix-ui/react-label 2.1.7
5:39:44 PM: + @radix-ui/react-navigation-menu 1.2.14
5:39:44 PM: + @radix-ui/react-scroll-area 1.2.10
5:39:44 PM: + @radix-ui/react-select 2.2.6
5:39:44 PM: + @radix-ui/react-slot 1.2.3
5:39:44 PM: + @radix-ui/react-tabs 1.1.13
5:39:44 PM: + @takumi-rs/core 0.36.2
5:39:44 PM: + @takumi-rs/helpers 0.36.2
5:39:44 PM: + @takumi-rs/image-response 0.36.2
5:39:44 PM: + ai 4.3.19
5:39:44 PM: + bson-objectid 2.0.4
5:39:44 PM: + class-variance-authority 0.7.1
5:39:44 PM: + clsx 2.1.1
5:39:44 PM: + cross-env 7.0.3
5:39:44 PM: + drizzle-kit 0.31.4
5:39:44 PM: + embla-carousel-react 8.6.0
5:39:44 PM: + geist 1.5.1
5:39:44 PM: + graphql 16.11.0
5:39:44 PM: + he 1.2.0
5:39:44 PM: + lucide 0.525.0
5:39:44 PM: + lucide-react 0.525.0
5:39:44 PM: + motion 12.23.22
5:39:44 PM: + next 15.5.4
5:39:44 PM: + next-intl 4.3.12
5:39:44 PM: + next-sitemap 4.2.3
5:39:44 PM: + payload 3.59.1
5:39:44 PM: + payload-admin-bar 1.0.7
5:39:44 PM: + pg-cloudflare 1.1.1
5:39:44 PM: + prism-react-renderer 2.4.1
5:39:44 PM: + radix-ui 1.4.3
5:39:44 PM: + react 19.2.0
5:39:44 PM: + react-circle-flags 0.0.23
5:39:44 PM: + react-dom 19.2.0
5:39:44 PM: + react-hook-form 7.60.0
5:39:44 PM: + react-phone-number-input 3.4.12
5:39:44 PM: + react-use-measure 2.1.7
5:39:44 PM: + sharp 0.34.2
5:39:44 PM: + tailwind-merge 3.3.1
5:39:44 PM: + tw-animate-css 1.4.0
5:39:44 PM: + use-debounce 10.0.6
5:39:44 PM: + zod 3.25.76
5:39:44 PM: devDependencies:
5:39:44 PM: + @eslint/eslintrc 3.3.1
5:39:44 PM: + @iconify-icon/react 3.0.1
5:39:44 PM: + @lexical/headless 0.35.0
5:39:44 PM: + @lexical/html 0.35.0
5:39:44 PM: + @lexical/selection 0.35.0
5:39:44 PM: + @lexical/utils 0.35.0
5:39:44 PM: + @tailwindcss/postcss 4.1.14
5:39:44 PM: + @tailwindcss/typography 0.5.19
5:39:44 PM: + @types/escape-html 1.0.4
5:39:44 PM: + @types/he 1.2.3
5:39:44 PM: + @types/node 24.0.10
5:39:44 PM: + @types/react 19.1.8
5:39:44 PM: + @types/react-dom 19.1.6
5:39:44 PM: + @wordpress/autop 4.31.0
5:39:44 PM: + cheerio 1.1.2
5:39:44 PM: + copyfiles 2.4.1
5:39:44 PM: + dotenv 17.2.3
5:39:44 PM: + eslint 9.37.0
5:39:44 PM: + eslint-config-next 15.3.5
5:39:44 PM: + eslint-plugin-unused-imports 4.2.0
5:39:44 PM: + fast-xml-parser 5.2.5
5:39:44 PM: + jsdom 27.0.0
5:39:44 PM: + lexical 0.35.0
5:39:44 PM: + mime 4.1.0
5:39:44 PM: + netlify-cli 23.9.5
5:39:44 PM: + postcss 8.5.6
5:39:44 PM: + prettier 3.6.2
5:39:44 PM: + prettier-plugin-tailwindcss 0.6.14
5:39:44 PM: + tailwindcss 4.1.14
5:39:44 PM: + tsx 4.20.6
5:39:44 PM: + typescript 5.8.3
5:39:44 PM: ╭ Warning ─────────────────────────────────────────────────────────────────────╮
5:39:44 PM: │                                                                              │
5:39:44 PM: │   Ignored build scripts: @parcel/watcher, @tailwindcss/oxide, bufferutil,    │
5:39:44 PM: │   esbuild, netlify-cli, sharp, unix-dgram, unrs-resolver, utf-8-validate.    │
5:39:44 PM: │   Run “pnpm approve-builds” to pick which dependencies should be allowed     │
5:39:44 PM: │   to run scripts.                                                            │
5:39:44 PM: │                                                                              │
5:39:44 PM: ╰──────────────────────────────────────────────────────────────────────────────╯
5:39:45 PM: Done in 45.1s using pnpm v10.19.0
5:39:45 PM: npm packages installed using pnpm
5:39:45 PM: Successfully installed dependencies
5:39:45 PM: Starting build script
5:39:46 PM: Detected 1 framework(s)
5:39:46 PM: “next” at version “15.5.4”
5:39:46 PM: Section completed: initializing
5:39:47 PM: ​
5:39:47 PM: Netlify Build
5:39:47 PM: ────────────────────────────────────────────────────────────────
5:39:47 PM: ​
5:39:47 PM: ❯ Version
5:39:47 PM:   @netlify/build 35.2.8
5:39:47 PM: ​
5:39:47 PM: ❯ Flags
5:39:47 PM:   accountId: 68dbbf33e28f1e08864f0b7d
5:39:47 PM:   baseRelDir: true
5:39:47 PM:   buildId: 6903787824de5700088e90d9
5:39:47 PM:   deployId: 6903787824de5700088e90db
5:39:47 PM: ​
5:39:47 PM: ❯ Current directory
5:39:47 PM:   /opt/build/repo
5:39:47 PM: ​
5:39:47 PM: ❯ Config file
5:39:47 PM:   No config file was defined: using default values.
5:39:47 PM: ​
5:39:47 PM: ❯ Context
5:39:47 PM:   production
5:39:48 PM: ​
5:39:48 PM: ❯ Installing extensions
5:39:48 PM:    - neon
5:40:05 PM: ​
5:40:05 PM: ❯ Using Next.js Runtime - v5.14.4
5:40:05 PM: ​
5:40:05 PM: ❯ Loading extensions
5:40:05 PM:    - neon
5:40:06 PM: No Next.js cache to restore
5:40:06 PM: ​
5:40:06 PM: Build command from Netlify app
5:40:06 PM: ────────────────────────────────────────────────────────────────
5:40:06 PM: ​
5:40:06 PM: $ pnpm run ci
5:40:06 PM: > marn-payload@1.0.0 ci /opt/build/repo
5:40:06 PM: > payload migrate:status && payload migrate && pnpm build
5:40:11 PM: [14:40:11] INFO: Reading migration files from /opt/build/repo/src/migrations
5:40:12 PM: ┌──────────────────────┬───────┬─────┐
5:40:12 PM: │                 Name │ Batch │ Ran │
5:40:12 PM: ├──────────────────────┼───────┼─────┤
5:40:12 PM: │ 20250527_185443_init │     1 │ Yes │
5:40:12 PM: │      20250528_175306 │     2 │ Yes │
5:40:12 PM: │      20250531_213347 │     3 │ Yes │
5:40:12 PM: │      20250601_090818 │     3 │ Yes │
5:40:12 PM: │      20250602_161514 │     4 │ Yes │
5:40:12 PM: │      20250612_142231 │     5 │ Yes │
5:40:12 PM: │      20250615_224916 │     6 │ Yes │
5:40:12 PM: │      20250623_212150 │     7 │ Yes │
5:40:12 PM: │      20250625_090956 │     8 │ Yes │
5:40:12 PM: │      20250626_153010 │     9 │ Yes │
5:40:12 PM: │      20250626_235408 │     9 │ Yes │
5:40:12 PM: │      20250701_095941 │    10 │ Yes │
5:40:12 PM: │      20250704_193410 │    11 │ Yes │
5:40:12 PM: │      20250705_214613 │    12 │ Yes │
5:40:12 PM: │      20250711_153038 │    13 │ Yes │
5:40:12 PM: │      20250720_225654 │    14 │ Yes │
5:40:12 PM: │      20250729_062832 │    15 │ Yes │
5:40:12 PM: │      20250730_182408 │    16 │ Yes │
5:40:12 PM: │      20250814_025853 │    17 │ Yes │
5:40:12 PM: │      20250817_140117 │    17 │ Yes │
5:40:12 PM: │      20250817_150457 │    17 │ Yes │
5:40:12 PM: │      20250817_153200 │    17 │ Yes │
5:40:12 PM: │      20250817_153358 │    17 │ Yes │
5:40:12 PM: │      20250902_095832 │    18 │ Yes │
5:40:12 PM: │      20250905_193052 │    19 │ Yes │
5:40:12 PM: │      20250906_094408 │    20 │ Yes │
5:40:12 PM: │      20250911_120550 │    21 │ Yes │
5:40:12 PM: │      20250921_231334 │    22 │ Yes │
5:40:12 PM: │      20250928_180852 │    23 │ Yes │
5:40:12 PM: │      20251013_212651 │    24 │ Yes │
5:40:12 PM: │      20251019_192209 │    25 │ Yes │
5:40:12 PM: │      20251025_201728 │    26 │ Yes │
5:40:12 PM: │      20251025_203921 │    27 │ Yes │
5:40:12 PM: │      20251025_204254 │    28 │ Yes │
5:40:12 PM: │      20251026_191129 │    29 │ Yes │
5:40:12 PM: │      20251026_211736 │    29 │ Yes │
5:40:12 PM: └──────────────────────┴───────┴─────┘
5:40:12 PM: [14:40:12] INFO: Done.
5:40:15 PM: [14:40:15] INFO: Reading migration files from /opt/build/repo/src/migrations
5:40:15 PM: [14:40:15] INFO: Done.
5:40:16 PM: > marn-payload@1.0.0 build /opt/build/repo
5:40:16 PM: > cross-env NODE_OPTIONS=–no-deprecation next build
5:40:17 PM: https://marn-web.netlify.app
5:40:17 PM: env:  production
5:40:17 PM: ⚠ No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
5:40:17 PM:    ▲ Next.js 15.5.4
5:40:17 PM:    Creating an optimized production build …
5:41:17 PM:  ✓ Compiled successfully in 60s
5:41:17 PM:    Linting and checking validity of types …
5:41:38 PM:    Collecting page data …
5:41:46 PM: NEXT_PUBLIC_SERVER_URL https://marn-web.netlify.app
5:41:57 PM:    Generating static pages (0/574) …

Build settings:

Your build seems to be running into memory limit:

I’d recommend adding:

experimental: {
  cpus: 1
}

to your next.config.js

Just tried that, and it looks like it now completes the Generating static pages (0/574) ... step, but it seems to be timing out (?) on the next step, building the actual pages.

8:43:32 PM:    Generating static pages (0/574) ...

8:43:33 PM: NEXT_PUBLIC_SERVER_URL https://marn-web.netlify.app

8:44:33 PM: Failed to build /(frontend)/[locale]/[...slug]/page: /en/solutions/marn-pay (attempt 1 of 3) because it took more than 60 seconds. Retrying again shortly.

8:44:33 PM: Failed to build /(frontend)/[locale]/[...slug]/page: /en/features/control (attempt 1 of 3) because it took more than 60 seconds. Retrying again shortly.

8:44:33 PM: Failed to build /(frontend)/[locale]/[...slug]/page: /en/food-truck (attempt 1 of 3) because it took more than 60 seconds. Retrying again shortly.

8:44:33 PM: Failed to build /(frontend)/[locale]/[...slug]/page: /en/restaurants (attempt 1 of 3) because it took more than 60 seconds. Retrying again shortly.

8:44:33 PM: Failed to build /(frontend)/[locale]/[...slug]/page: /en/retail (attempt 1 of 3) because it took more than 60 seconds. Retrying again shortly.

8:44:33 PM: Failed to build /(frontend)/[locale]/[...slug]/page: /en/blog (attempt 1 of 3) because it took more than 60 seconds. Retrying again shortly.

8:45:34 PM: Failed to build /(frontend)/[locale]/[...slug]/page: /en/solutions/marn-pay (attempt 2 of 3) because it took more than 60 seconds. Retrying again shortly.

8:45:34 PM: Failed to build /(frontend)/[locale]/[...slug]/page: /en/blog (attempt 2 of 3) because it took more than 60 seconds. Retrying again shortly.

8:45:34 PM: Failed to build /(frontend)/[locale]/[...slug]/page: /en/restaurants (attempt 2 of 3) because it took more than 60 seconds. Retrying again shortly.

8:45:34 PM: Failed to build /(frontend)/[locale]/[...slug]/page: /en/food-truck (attempt 2 of 3) because it took more than 60 seconds. Retrying again shortly.

8:45:34 PM: Failed to build /(frontend)/[locale]/[...slug]/page: /en/features/control (attempt 2 of 3) because it took more than 60 seconds. Retrying again shortly.

8:45:34 PM: Failed to build /(frontend)/[locale]/[...slug]/page: /en/retail (attempt 2 of 3) because it took more than 60 seconds. Retrying again shortly.

8:46:35 PM: Failed to build /(frontend)/[locale]/[...slug]/page: /en/solutions/marn-pay after 3 attempts.

8:46:35 PM: Export encountered an error on /(frontend)/[locale]/[...slug]/page: /en/solutions/marn-pay, exiting the build.

8:46:35 PM:  ⨯ Next.js build worker exited with code: 1 and signal: null

8:46:35 PM:  ELIFECYCLE  Command failed with exit code 1. (https://ntl.fyi/exit-code-1)

8:46:35 PM:  ELIFECYCLE  Command failed with exit code 1. (https://ntl.fyi/exit-code-1)

8:46:36 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)

What’s the code for /en/solutions/marn-pay? Is there something that’s taking long?

Essentially this page and the others are under a Nextjs Dynamic Route where I’m fetching some data from a CMS with postgres (Neon) database (us-east-2) and passing it down to a component that renders it. Nothing should take too long.

import type { Metadata } from ‘next’

import { PayloadRedirects } from ‘@/components/PayloadRedirects’
import configPromise from ‘@payload-config’
import { getPayload } from ‘payload’
import { draftMode } from ‘next/headers’
import React, { cache } from ‘react’

import type { Page as PageType } from ‘@/payload-types’

import { RenderBlocks } from ‘@/blocks/RenderBlocks’
import { RenderHero } from ‘@/heros/RenderHero’
import { generateMeta } from ‘@/utilities/generateMeta’
import PageClient from ‘./page.client’
import { LivePreviewListener } from ‘@/components/LivePreviewListener’

export async function generateStaticParams() {
const payload = await getPayload({ config: configPromise })
const locales = [‘en’, ‘ar’]
const params: { slug: string
; locale: ‘ar’ | ‘en’ }
 = 

for (const locale of locales) {
const pages = await payload.find({
collection: ‘pages’,
locale: locale as ‘ar’ | ‘en’,
draft: false,
limit: 1000,
overrideAccess: false,
pagination: false,
select: {
slug: true,
},
})
pages.docs
?.filter((doc) => {
return doc.slug && doc.slug !== ‘home’
})
.map((doc) => {
params.push({
slug: doc.slug?.split(‘/’) || 
,
locale: locale as ‘ar’ | ‘en’,
})
})
}
return params
}

type Args = {
params: Promise<{
slug?: string

locale?: ‘ar’ | ‘en’ | undefined
}>
}

export default async function Page({ params }: Args) {
const { isEnabled: draft } = await draftMode()
const { slug: slugSegments = [‘home’], locale = ‘ar’ } = await params
const slugPath = slugSegments.join(‘/’) || ‘home’
const url = /${locale}/${slugPath}

let page: PageType | null

page = await queryPageBySlug({
slug: slugPath,
locale,
})

if (!page && slugPath === ‘home’) {
page = null
}

if (!page) {
return 
}

const { hero, layout } = page

return (




  {draft && <LivePreviewListener />}

  <RenderHero {...hero} />
  <RenderBlocks blocks={layout as any} locale={locale} />
</article>

)
}

export async function generateMetadata({ params }: Args): Promise {
const awaitedp = await params
const { slug: slugSegments = [‘home’], locale = ‘ar’ } = await params

const slugPath = slugSegments.join(‘/’) || ‘home’

const page = await queryPageBySlug({
slug: slugPath,
locale,
})
const meta = await generateMeta({ doc: page, locale })

return meta
}

const queryPageBySlug = cache(async ({ slug, locale }: { slug: string; locale?: ‘ar’ | ‘en’ }) => {
const { isEnabled: draft } = await draftMode()

const payload = await getPayload({ config: configPromise })

const result = await payload.find({
collection: ‘pages’,
locale: locale,
draft,
limit: 1,
pagination: false,
overrideAccess: draft,
where: {
slug: {
equals: slug,
},
},
})

return result.docs?.[0] || null
})

Not sure if this is relevant, but the standard build machine on Vercel is 4 vCPUs, 8 GB Memory, and it works just fine over there.

Thanks @hrishikesh . Apparently, the Nextjs server needed more resource than available for the build machine to generate static HTML for ~574 pages. In case anyone is facing a similar issue, I was able to solve it by setting experimental.cpus = 1 from the next config, setting

export const dynamic = ‘force-static’
export const revalidate = 86400 // 24h

in page.tsx for that route, and removing generateStaticParams(). This stops the server from generating the static pages during build time, but const dynamic = ‘force-static’ makes it so they’re prerendered as static content on the server during build time instead. The page will finally be rendered on the server only the first time it is requested–causing that first load to be slow. Set a long revalidation time with const revalidate = 86400 so the page is served from cache after that first slow page load, and then you’re free to revalidate the path with revalidatePath() or revalidateTag() when content is updated.

Sorry, I marked this as solution too early. It seems like although the build succeeds and the project is deployed successfully, pages don’t actually load.