amplify-hosting icon indicating copy to clipboard operation
amplify-hosting copied to clipboard

NextJS 12 frontend build throws "No build cache found. Please configure build caching for faster rebuilds" warning

Open LucasLemanowicz opened this issue 2 years ago • 20 comments

Before opening, please confirm:

  • [X] I have checked to see if my question is addressed in the FAQ.
  • [X] I have searched for duplicate or closed issues.
  • [X] I have read the guide for submitting bug reports.
  • [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • [X] I have removed any sensitive information from my code snippets and submission.

App Id

d2gl6gra9yo4lf

AWS Region

us-west-2

Amplify Hosting feature

Frontend builds

Describe the bug

NextJS 12 build cache does not seem to be working for me on AWS Amplify. I have a monorepo with the frontend hosted in a subdirectory, and my amplify.yml configuration looks like this:

version: 1
applications:
  - frontend:
      phases:
        preBuild:
          commands:
            - nvm install 14
            - nvm use 14
            - yarn install
        build:
          commands:
            - nvm use 14
            - yarn run build:$BUILD_TYPE
        test:
          commands:
            - nvm use 14
            - yarn run test:$BUILD_TYPE
      artifacts:
        baseDirectory: .next
        files:
          - '**/*'
      cache:
        paths:
          - '.next/cache/**/*'
          - 'node_modules/**/*'
    appRoot: path/to/frontend

When I run a build, I see the following warning message in my frontend build logs:

warn  - No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache

Expected behavior

I expect the build cache to be found.

Reproduction steps

  1. See the config above

Build Settings

No response

Log output

# Put your logs below this line


Additional information

No response

LucasLemanowicz avatar Dec 19 '22 18:12 LucasLemanowicz

+1. Thought this was addressed per https://github.com/aws-amplify/amplify-hosting/issues/2436#issuecomment-1319187238 but the issue remains

ChristopherBanas avatar Dec 19 '22 21:12 ChristopherBanas

up, anybody?

lucaswiix avatar Mar 16 '23 08:03 lucaswiix

+1

sators avatar Mar 16 '23 20:03 sators

+1

borisyordanov avatar Apr 04 '23 19:04 borisyordanov

+2

codenimble avatar Apr 08 '23 22:04 codenimble

Yeah, I'm also experiencing this on a time critical project..

error-try-again avatar Apr 18 '23 23:04 error-try-again

same here

70ki8suda avatar May 09 '23 07:05 70ki8suda

+1

yrkimyy avatar Jun 02 '23 05:06 yrkimyy

+1

petitgen avatar Jun 04 '23 18:06 petitgen

I switched over to Vercel. Much better experience

ChristopherBanas avatar Jun 05 '23 23:06 ChristopherBanas

Likewise.

We switched over to Vercel a couple weeks ago after AWS Amplify broke our build (claiming our bundle size was suddenly several times over the limit on builds that built fine the day before). Their support team tried to blame it on us, and after going back and forth debugging with them for several days they finally acknowledged that it was an issue on their side and told us they had no short term fix for it.

I would not risk running any production NextJS application on AWS Amplify ever again after this experience. I know they have smart engineers and an over-worked support team that are trying their hardest to help us, but it is quite apparent that AWS as an organization is not investing in Amplify or treating it as a first-class product.

In terms of your other options:

  • Vercel builds are significantly faster, all of NextJS' features that we use were supported with no issues, and their support is responsive and helpful. The migration required almost no code changes.
  • We also explored CloudFlare Pages as an option and had our site building there without issues within a couple of hours as well.
  • We looked at Netlify and Render but did not invest in getting our app to build on there once we had it working on the first two providers.

LucasLemanowicz avatar Jun 05 '23 23:06 LucasLemanowicz

@LucasLemanowicz This exact issue just happened to us last night and I've been debugging ever since. Went from ~120MB to suddenly ~750MB build output with a single small code commit.

Glad to know I'm not alone.

foobarnes avatar Sep 12 '23 19:09 foobarnes

+1

ornakash avatar Sep 19 '23 20:09 ornakash

+1

MichOchieng avatar Oct 09 '23 06:10 MichOchieng

+1

righteousgambit avatar Oct 26 '23 00:10 righteousgambit

+1

belei-bohdan avatar Nov 05 '23 11:11 belei-bohdan

+1

nnti3n avatar Nov 06 '23 04:11 nnti3n

Is there any update here?

jordanpurinton avatar Dec 19 '23 20:12 jordanpurinton

+1

eviannaive avatar Jan 03 '24 07:01 eviannaive

+1

kilianheinrich avatar Feb 01 '24 08:02 kilianheinrich

Hi everyone 👋 , we have updated our documentation with the following troubleshooting guide: https://docs.aws.amazon.com/amplify/latest/userguide/troubleshooting-ssr-deployment.html#build-output-too-large. This guide should enable you to:

  • Download and inspect your build artifacts
  • Analyze the .next directory and the build cache directory within it
  • Measure the size of your compute and static directories
  • Review the dependencies within the node_modules folder
  • Delete the binaries that aren't required at runtime

Additionally, to improve build performance and to persist the cache between builds Amplify Hosting now adds the following cache paths by default to your buildSpec:

cache:
  paths:
    - node_modules/**/* # Cache `node_modules` for faster `yarn` or `npm i`
    - .next/cache/**/* # Cache Next.js for faster application rebuilds

Jay2113 avatar Mar 01 '24 22:03 Jay2113

This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.

github-actions[bot] avatar Mar 01 '24 22:03 github-actions[bot]

This issue has been automatically locked.

github-actions[bot] avatar Mar 01 '24 23:03 github-actions[bot]