Nextjs@12.2.2项目Firebase部署Hosting触发无效函数报错
问题
我有一个基于Nextjs@12.2.2的项目,在Firebase部署时遇到异常:
- 执行
firebase deploy --only functions可成功部署所有云函数(项目中不存在名为ssrcasavelerosbotevbl的函数); - 执行
firebase deploy --only hosting时,系统会同时部署Hosting和Functions,且尝试创建已删除的ssrcasavelerosbotevbl函数,因CPU配置/配额问题报错,导致无法更新网页。
单独部署Functions的成功日志
=== Deploying to 'casavelerosbot-evbl'... i deploying functions i functions: preparing codebase default for deployment i functions: ensuring required API cloudfunctions.googleapis.com is enabled... i functions: ensuring required API cloudbuild.googleapis.com is enabled... i artifactregistry: ensuring required API artifactregistry.googleapis.com is enabled... ✔ functions: required API cloudbuild.googleapis.com is enabled ✔ artifactregistry: required API artifactregistry.googleapis.com is enabled ✔ functions: required API cloudfunctions.googleapis.com is enabled i functions: preparing functions directory for uploading... i functions: packaged /Users/luisquiroga/Documents/GitHub/casavelerosweb/functions (109.88 KB) for uploading ✔ functions: functions folder uploaded successfully i functions: updating Node.js 16 function onAccountCreate(us-central1)... i functions: updating Node.js 16 function createProperty(us-central1)... i functions: updating Node.js 16 function editProperty(us-central1)... i functions: updating Node.js 16 function addMember(us-central1)... i functions: updating Node.js 16 function removeMember(us-central1)... i functions: updating Node.js 16 function createReservation(us-central1)... i functions: updating Node.js 16 function editReservation(us-central1)... i functions: updating Node.js 16 function updateReservationStatus(us-central1)... i functions: updating Node.js 16 function removeReservation(us-central1)... i functions: updating Node.js 16 function createTransaction(us-central1)... i functions: updating Node.js 16 function editTransaction(us-central1)... i functions: updating Node.js 16 function removeTransaction(us-central1)... ✔ functions[createTransaction(us-central1)] Successful update operation. ✔ functions[removeReservation(us-central1)] Successful update operation. ✔ functions[editProperty(us-central1)] Successful update operation. ✔ functions[editTransaction(us-central1)] Successful update operation. ✔ functions[removeMember(us-central1)] Successful update operation. ✔ functions[removeTransaction(us-central1)] Successful update operation. ✔ functions[editReservation(us-central1)] Successful update operation. ✔ functions[createReservation(us-central1)] Successful update operation. ✔ functions[updateReservationStatus(us-central1)] Successful update operation. ✔ functions[createProperty(us-central1)] Successful update operation. ✔ functions[addMember(us-central1)] Successful update operation. ✔ functions[onAccountCreate(us-central1)] Successful update operation. i functions: cleaning up build files... ✔ Deploy complete!
部署Hosting时的报错日志
=== Deploying to 'casavelerosbot-evbl'... i deploying functions, hosting i functions: preparing codebase default for deployment i functions: preparing codebase firebase-frameworks-casavelerosbot-evbl for deployment i functions: ensuring required API cloudfunctions.googleapis.com is enabled... i functions: ensuring required API cloudbuild.googleapis.com is enabled... i artifactregistry: ensuring required API artifactregistry.googleapis.com is enabled... ✔ functions: required API cloudfunctions.googleapis.com is enabled ✔ functions: required API cloudbuild.googleapis.com is enabled ✔ artifactregistry: required API artifactregistry.googleapis.com is enabled ⚠ functions: package.json indicates an outdated version of firebase-functions. Please upgrade using npm install --save firebase-functions@latest in your functions directory. ⚠ functions: Please note that there will be breaking changes when you upgrade. i functions: Loaded environment variables from .env. i functions: preparing functions directory for uploading... i functions: packaged /Users/luisquiroga/Documents/GitHub/casavelerosweb/functions (159.33 KB) for uploading i functions: preparing .firebase/casavelerosbot-evbl/functions directory for uploading... i functions: packaged /Users/luisquiroga/Documents/GitHub/casavelerosweb/.firebase/casavelerosbot-evbl/functions (21.22 MB) for uploading i functions: ensuring required API run.googleapis.com is enabled... i functions: ensuring required API eventarc.googleapis.com is enabled... i functions: ensuring required API pubsub.googleapis.com is enabled... i functions: ensuring required API storage.googleapis.com is enabled... ✔ functions: required API pubsub.googleapis.com is enabled ✔ functions: required API storage.googleapis.com is enabled ✔ functions: required API run.googleapis.com is enabled ✔ functions: required API eventarc.googleapis.com is enabled i functions: generating the service identity for pubsub.googleapis.com... i functions: generating the service identity for eventarc.googleapis.com... ✔ functions: functions folder uploaded successfully ✔ functions: .firebase/casavelerosbot-evbl/functions folder uploaded successfully i hosting[casavelerosbot-evbl]: beginning deploy... i hosting[casavelerosbot-evbl]: found 71 files in .firebase/casavelerosbot-evbl/hosting ✔ hosting[casavelerosbot-evbl]: file upload complete i functions: creating Node.js 16 function firebase-frameworks-casavelerosbot-evbl:ssrcasavelerosbotevbl(us-central1)... ⚠ functions: HTTP Error: 400, Could not create Cloud Run service ssrcasavelerosbotevbl. spec.template.spec.containers.resources.limits.cpu: Invalid value specified for cpu. For the specified value, maxScale may not exceed 10. Consider running your workload in a region with greater capacity, decreasing your requested cpu-per-instance, or requesting an increase in quota for this region if you are seeing sustained usage near this limit, see https://cloud.google.com/run/quotas. Your project may gain access to further scaling by adding billing information to your account. ⚠ functions: failed to create function projects/casavelerosbot-evbl/locations/us-central1/functions/ssrcasavelerosbotevbl Failed to create function projects/casavelerosbot-evbl/locations/us-central1/functions/ssrcasavelerosbotevbl Functions deploy had errors with the following functions: firebase-frameworks-casavelerosbot-evbl:ssrcasavelerosbotevbl(us-central1) i functions: cleaning up build files... Error: There was an error deploying functions
相关配置文件
firebase.json
{ "functions": [ { "source": "functions", "codebase": "default", "ignore": [ "node_modules", ".git", "firebase-debug.log", "firebase-debug.*.log" ] } ], "firestore": { "rules": "firestore.rules", "indexes": "firestore.indexes.json" }, "hosting": { "source": ".", "ignore": [ "firebase.json", "**/.*", "**/node_modules/**" ], "frameworksBackend": { "region": "us-central1" } }, "storage": { "rules": "storage.rules" } }
前端package.json
{ "name": "casavelerosweb", "version": "0.1.1", "private": true, "scripts": { "dev": "next dev", "build": "next build && next export", "start": "next start", "lint": "next lint" }, "dependencies": { "@date-io/moment": "^2.16.1", "@emotion/react": "^11.10.5", "@emotion/styled": "^11.10.5", "@fontsource/roboto": "^4.5.8", "@mui/icons-material": "^5.11.0", "@mui/lab": "^5.0.0-alpha.122", "@mui/material": "^5.11.4", "@mui/styles": "^5.11.2", "@mui/x-date-pickers": "^5.0.13", "@next/font": "13.1.2", "dayjs": "^1.11.7", "eslint": "8.31.0", "eslint-config-next": "13.1.2", "firebase": "^9.18.0", "firebase-admin": "^11.5.0", "lodash": "^4.17.21", "moment": "^2.29.4", "next": "12.2.2", "react": "^17.0.2", "react-dom": "^17.0.2", "react-firebase-hooks": "^5.1.1", "react-firebaseui": "^6.0.0" } }
Functions的package.json
{ "name": "functions", "description": "Cloud Functions for Firebase", "scripts": { "lint": "eslint .", "serve": "firebase emulators:start --only functions", "shell": "firebase functions:shell", "start": "npm run shell", "deploy": "firebase deploy --only functions", "logs": "firebase functions:log" }, "engines": { "node": "16" }, "main": "index.js", "dependencies": { "firebase-admin": "^11.5.0", "firebase-functions": "^4.2.1", "request": "^2.88.2", "twilio": "^2.5.2" }, "devDependencies": { "eslint": "^8.9.0", "eslint-config-google": "^0.14.0", "firebase-functions-test": "^0.2.0" }, "private": true }
Firebase控制台函数列表截图

内容的提问来源于stack exchange,提问作者Luis Quiroga
相关产品推荐
相关产品推荐

