Build exceeded memory limit for previews

I keep receiving the following error for preview builds - Failed: build exceeded memory limit and was terminated. What are my options to prevent this from happening? Is there some way to increase memory resources during build?

Pages builds get ~8GB of memory for building their projects. Can you share any more information about what you’re building that requires more memory than this?

Sure, its nothing crazy just a Nuxt-based frontend. Here is the github workflow im using for deployment:

name: CF Pages Deployment

on:
  workflow_call:

jobs:
  ci:
    runs-on: ${{ matrix.os }}

    strategy:
      matrix:
        os: [ubuntu-latest]
        node: [16.14]

    steps:
      - uses: actions/setup-node@v1
        with:
          node-version: 16.14

      - name: Checkout
        uses: actions/checkout@v3

      - name: Install Dependencies
        run: npm install --force
        
      - name: Create env file
        run: |
          echo "${{ secrets.ENV_FILE }}" > .env

      - name: Build
        run: npx nuxt build
        env:  
          NITRO_PRESET: cloudflare_pages

      - name: Publish to CF Pages
        uses: cloudflare/pages-action@v1
        with:
          apiToken: ${{ secrets.CF_API_TOKEN }}
          accountId: ==REDACTED==
          projectName: frontend
          directory: dist
          gitHubToken: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
          branch: development
          wranglerVersion: '3'

The strange part is that if I re-run the build, it pretty much works every time. Just not automatically.

So I ran another build and watched the logs this time, and it seems that it runs the following command repeatedly:

$ NITRO_PRESET=cloudflare_pages yarn build

The lines prior to these duplicate commands shows

Executing user command: yarn build
yarn run v1.22.4

Does CF workers not support yarn?

I’m a little confused. Are you using Pages CI, or GitHub Actions with Pages Direct Upload to publish your project? Are you hitting memory limits in Pages CI, or in GitHub Actions?

Sorry, let me clarify - Im using Github Actions w/ Pages Direct upload for deployments to dev and prod environments (probably why they work every time), and then having Pages auto build for previews on branches that haven’t been merged yet with dev or prod environment. The Pages direct upload seems to work fine, its just whenever Cloudflare attempts to build for the previews I get the duplicated yarn commands issue.