GoogleCloudPlatform / buildpacks

Builders and buildpacks designed to run on Google Cloud's container platforms
Apache License 2.0
967 stars 144 forks source link

NextJS deploys failing due to NextJS App Hosting Adapter v14.0.5 #440

Open llwire opened 1 month ago

llwire commented 1 month ago

Describe the bug

Deploys for NextJS backends are failing due to the recent version update in the NextJS apphosting adapter.

After combing through the logs for my last successful deploy and the first failing deploy, I noticed that the only difference was that the @apphosting/adapter-nextjs version was bumped up to version 14.0.5 in the failing case. I believe this is the cause of the issues. All of my failing deploy install and try to run 14.0.5.

Those two deploys were just over an hour apart and the only change between the two commits a text change, so it would not affect deploys.

Additional context How are you using GCP buildpacks?

Did this used to work? Yes, it used to work.

The last working deploy and first failing deploy were 1hr and 10mins apart, with no breaking code changes.

What language is your project primarily written in? Node.js

Steps To Reproduce Steps to reproduce the behavior:

  1. Anything that triggers a deploy

Expected behavior The app to deploy.

Actual behavior ERROR: failed to build: exit status 1 ERROR: failed to build: executing lifecycle: failed with status code: 51

Success Log Snippet

2024-07-25 01:44:14.143 EDT
Step #2: === Node.js - Firebasenextjs (google.nodejs.firebasenextjs@0.0.1) ===
2024-07-25 01:44:14.145 EDT
Step #2: WARNING: *** You are using a custom build command (your build command is NOT 'next build'), we will accept it as is but will error if output structure is not as expected ***
2024-07-25 01:44:14.145 EDT
Step #2: ***** CACHE MISS: "npm_modules"
2024-07-25 01:44:14.146 EDT
Step #2: Installing nextjs adaptor 14.0.4
2024-07-25 01:44:16.869 EDT
Step #2: === Node.js - Yarn (google.nodejs.yarn@2.1.0) ===
2024-07-25 01:44:16.869 EDT
Step #2: 2024/07/25 05:44:16 [DEBUG] GET https://registry.npmjs.org/yarn
2024-07-25 01:44:16.973 EDT
Step #2: ***** CACHE MISS: "yarn_engine"
2024-07-25 01:44:16.974 EDT
Step #2: Installing Yarn v1.22.22
2024-07-25 01:44:16.974 EDT
Step #2: 2024/07/25 05:44:16 [DEBUG] GET https://yarnpkg.com/downloads/1.22.22/yarn-v1.22.22.tar.gz
2024-07-25 01:44:17.534 EDT
Step #2: Setting environment variable PATH=/layers/google.nodejs.yarn/yarn_engine/bin:/layers/google.nodejs.runtime/node/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
2024-07-25 01:44:17.552 EDT
Step #2: ***** CACHE MISS: "yarn_modules"
2024-07-25 01:44:17.553 EDT
Step #2: --------------------------------------------------------------------------------
2024-07-25 01:44:17.553 EDT
Step #2: Running "yarn install --non-interactive --prefer-offline --modules-folder=/layers/google.nodejs.yarn/yarn_modules/node_modules --frozen-lockfile --production=false (PATH=/layers/google.nodejs.yarn/yarn_engine/bin:/layers/google.nodejs.runtime/node/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/layers/google.nodejs.yarn/yarn_modules/node_modules/.bin)"
2024-07-25 01:44:17.929 EDT
Step #2: yarn install v1.22.22
2024-07-25 01:44:18.045 EDT
Step #2: [1/4] Resolving packages...
2024-07-25 01:44:18.670 EDT
Step #2: [2/4] Fetching packages...
2024-07-25 01:45:11.713 EDT
Step #2: [3/4] Linking dependencies...
2024-07-25 01:45:11.741 EDT
Step #2: warning " > @graphql-codegen/typescript-react-apollo@4.3.0" has unmet peer dependency "graphql-tag@^2.0.0".
2024-07-25 01:45:34.769 EDT
Step #2: [4/4] Building fresh packages...
2024-07-25 01:45:35.604 EDT
Step #2: Done in 77.68s.
2024-07-25 01:45:35.646 EDT
Step #2: Done "yarn install --non-interactive --prefer-offline --modules-fo..." (1m18.092596983s)
2024-07-25 01:45:35.646 EDT
Step #2: --------------------------------------------------------------------------------
2024-07-25 01:45:35.646 EDT
Step #2: Running "npm exec --prefix /layers/google.nodejs.firebasenextjs/npm_modules apphosting-adapter-nextjs-build"
2024-07-25 01:45:36.427 EDT
Step #2: 
2024-07-25 01:45:36.428 EDT
Step #2: > infinit-spaces@0.1.0 build
2024-07-25 01:45:36.428 EDT
Step #2: > next build
2024-07-25 01:45:36.645 EDT
Step #2: yarn run v1.22.22
2024-07-25 01:45:37.253 EDT
Step #2: 
2024-07-25 01:45:37.267 EDT
Step #2: Done in 0.63s.
2024-07-25 01:45:38.171 EDT
Step #2:   ▲ Next.js 14.2.3
2024-07-25 01:45:38.172 EDT
Step #2: 
2024-07-25 01:45:38.193 EDT
Step #2:    Creating an optimized production build ...
2024-07-25 01:46:30.648 EDT
Step #2:  ✓ Compiled successfully

Failure Log Snippet

2024-07-25 14:51:00.928 EDT
Step #2: === Node.js - Firebasenextjs (google.nodejs.firebasenextjs@0.0.1) ===
2024-07-25 14:51:00.930 EDT
Step #2: WARNING: *** You are using a custom build command (your build command is NOT 'next build'), we will accept it as is but will error if output structure is not as expected ***
2024-07-25 14:51:00.930 EDT
Step #2: ***** CACHE MISS: "npm_modules"
2024-07-25 14:51:00.931 EDT
Step #2: Installing nextjs adaptor 14.0.5
2024-07-25 14:51:04.210 EDT
Step #2: === Node.js - Yarn (google.nodejs.yarn@2.1.0) ===
2024-07-25 14:51:04.210 EDT
Step #2: 2024/07/25 18:51:04 [DEBUG] GET https://registry.npmjs.org/yarn
2024-07-25 14:51:04.346 EDT
Step #2: ***** CACHE MISS: "yarn_engine"
2024-07-25 14:51:04.347 EDT
Step #2: Installing Yarn v1.22.22
2024-07-25 14:51:04.347 EDT
Step #2: 2024/07/25 18:51:04 [DEBUG] GET https://yarnpkg.com/downloads/1.22.22/yarn-v1.22.22.tar.gz
2024-07-25 14:51:04.895 EDT
Step #2: Setting environment variable PATH=/layers/google.nodejs.yarn/yarn_engine/bin:/layers/google.nodejs.runtime/node/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
2024-07-25 14:51:04.912 EDT
Step #2: ***** CACHE MISS: "yarn_modules"
2024-07-25 14:51:04.914 EDT
Step #2: --------------------------------------------------------------------------------
2024-07-25 14:51:04.914 EDT
Step #2: Running "yarn install --non-interactive --prefer-offline --modules-folder=/layers/google.nodejs.yarn/yarn_modules/node_modules --frozen-lockfile --production=false (PATH=/layers/google.nodejs.yarn/yarn_engine/bin:/layers/google.nodejs.runtime/node/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/layers/google.nodejs.yarn/yarn_modules/node_modules/.bin)"
2024-07-25 14:51:05.297 EDT
Step #2: yarn install v1.22.22
2024-07-25 14:51:05.420 EDT
Step #2: [1/4] Resolving packages...
2024-07-25 14:51:06.065 EDT
Step #2: [2/4] Fetching packages...
2024-07-25 14:52:03.232 EDT
Step #2: [3/4] Linking dependencies...
2024-07-25 14:52:03.270 EDT
Step #2: warning " > @graphql-codegen/typescript-react-apollo@4.3.0" has unmet peer dependency "graphql-tag@^2.0.0".
2024-07-25 14:52:27.858 EDT
Step #2: [4/4] Building fresh packages...
2024-07-25 14:52:28.737 EDT
Step #2: Done in 83.45s.
2024-07-25 14:52:28.781 EDT
Step #2: Done "yarn install --non-interactive --prefer-offline --modules-fo..." (1m23.867885204s)
2024-07-25 14:52:28.782 EDT
Step #2: --------------------------------------------------------------------------------
2024-07-25 14:52:28.782 EDT
Step #2: Running "npm exec --prefix /layers/google.nodejs.firebasenextjs/npm_modules apphosting-adapter-nextjs-build"
2024-07-25 14:54:01.403 EDT
Step #2: /layers/google.nodejs.firebasenextjs/npm_modules/node_modules/@apphosting/common/dist/index.js:22
2024-07-25 14:54:01.403 EDT
Step #2:                 reject(new Error(`Process exited with error code ${code}. Output: ${buildOutput}`));
2024-07-25 14:54:01.403 EDT
Step #2:                        ^
2024-07-25 14:54:01.403 EDT
Step #2: 
2024-07-25 14:54:01.403 EDT
Step #2: Error: Process exited with error code 1.
donpui commented 1 month ago

I have exactly the same issue. Also tried pack locally, get also the same issue: pack build --builder=gcr.io/buildpacks/firebase-app-hosting-22/builder:latest <project>

builder] Running "npm ci --quiet (NODE_ENV=development)"
[builder] npm warn deprecated rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
[builder] npm warn deprecated npmlog@5.0.1: This package is no longer supported.
[builder] npm warn deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
[builder] npm warn deprecated gauge@3.0.2: This package is no longer supported.
[builder] npm warn deprecated are-we-there-yet@2.0.0: This package is no longer supported.
[builder] npm warn deprecated @humanwhocodes/object-schema@2.0.3: Use @eslint/object-schema instead
[builder] npm warn deprecated @humanwhocodes/config-array@0.11.14: Use @eslint/config-array instead
[builder] npm warn deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
[builder] 
[builder] added 579 packages, and audited 580 packages in 35s
[builder] 
[builder] 147 packages are looking for funding
[builder]   run `npm fund` for details
[builder] 
[builder] found 0 vulnerabilities
[builder] Done "npm ci --quiet (NODE_ENV=development)" (35.019103975s)
[builder] --------------------------------------------------------------------------------
[builder] Running "npm exec --prefix /layers/google.nodejs.firebasenextjs/npm_modules apphosting-adapter-nextjs-build"
[builder] Done "npm exec --prefix /layers/google.nodejs.firebasenextjs/npm_m..." (1m12.641180659s)
[builder] --------------------------------------------------------------------------------
[builder] Running "npm prune --production"
[builder] npm warn config production Use `--omit=dev` instead.
[builder] 
[builder] up to date, audited 267 packages in 2s
[builder] 
[builder] 19 packages are looking for funding
[builder]   run `npm fund` for details
[builder] 
[builder] found 0 vulnerabilities
[builder] Done "npm prune --production" (2.002502209s)
[builder] === Node.js - Firebasebundle (google.nodejs.firebasebundle@0.0.1) ===
[builder] --------------------------------------------------------------------------------
[builder] failed to build: (error ID: 6fa8e297):
[builder] looking up output bundle env FIREBASE_OUTPUT_BUNDLE_DIR
[builder] --------------------------------------------------------------------------------
[builder] Sorry your project couldn't be built.
[builder] Our documentation explains ways to configure Buildpacks to better recognise your project:
[builder]  -> https://cloud.google.com/docs/buildpacks/overview
[builder] If you think you've found an issue, please report it:
[builder]  -> https://github.com/GoogleCloudPlatform/buildpacks/issues/new
[builder] --------------------------------------------------------------------------------
[builder] Timer: Builder ran for 2m7.854129725s and ended at 2024-08-05T08:33:45Z
[builder] ERROR: failed to build: exit status 1
ERROR: failed to build: executing lifecycle: failed with status code: 51
zuldy commented 1 month ago

I also have the same issue, started yesterday.

INFO 2024-08-05T09:41:26.110880799Z Step #2: Sorry your project couldn't be built.
INFO 2024-08-05T09:41:26.110881335Z Step #2: Our documentation explains ways to configure Buildpacks to better recognise your project:
INFO 2024-08-05T09:41:26.110881796Z Step #2: -> https://cloud.google.com/docs/buildpacks/overview
INFO 2024-08-05T09:41:26.110890419Z Step #2: If you think you've found an issue, please report it:
INFO 2024-08-05T09:41:26.110890934Z Step #2: -> https://github.com/GoogleCloudPlatform/buildpacks/issues/new
INFO 2024-08-05T09:41:26.110891434Z Step #2: --------------------------------------------------------------------------------
INFO 2024-08-05T09:41:26.112499817Z Step #2: Timer: Builder ran for 2m9.077105853s and ended at 2024-08-05T09:41:26Z
INFO 2024-08-05T09:41:26.112510126Z Step #2: ERROR: failed to build: exit status 1
INFO 2024-08-05T09:41:29.862577282Z Step #2: ERROR: failed to build: executing lifecycle: failed with status code: 51
INFO 2024-08-05T09:41:30.107040511Z Finished Step #2
INFO 2024-08-05T09:41:30.107233481Z ERROR
INFO 2024-08-05T09:41:30.107260485Z ERROR: build step 2 "gcr.io/k8s-skaffold/pack" failed: step exited with non-zero status: 1
dorraba commented 1 month ago

Any updates on this? happens to me too

Yuangwang commented 1 month ago

Hi Firebase employee here, thank you for bringing this up. We are looking into it now and will provide updates in this thread

llwire commented 1 month ago

Hey, just checking if there is any update on this? It's a bit of a blocker for me, this getting fixed would be a major help.

Thanks in advance!

Yuangwang commented 1 month ago

Hi, yes we've identified the issue and merged the fix in https://github.com/FirebaseExtended/firebase-framework-tools/pull/237.

We're currently rolling out the fix to everyone so please try to rerun your build in the coming days

connershoop commented 1 month ago

Can confirm this fixed my issue, can now see app hosting deployment errors properly

llwire commented 4 weeks ago

Same here - I can see the deployment errors properly.

In my case, the error was that the firebase Admin initializeApp() call was missing config parameters. This is strange because the application should have been used but it wasn't, and that didn't seem to be an issue until the update I referenced above.

For now I get by with the code below, but I wonder if there is more to uncover here.

firebaseAdminApp = admin.initializeApp({
  projectId: firebaseConfig.projectId,
  credential: applicationDefault(),
});