Aug*_*sto 7 javascript node.js firebase google-cloud-platform google-cloud-functions
我在将预定功能部署到 Firebase 时遇到一些问题。这是我的问题之一。
\n在功能部署中,我可以捕获(我认为的)主要错误原因:
\nDetailed stack trace: TypeError: async_hooks_1.AsyncLocalStorage is not a constructor\nRun Code Online (Sandbox Code Playgroud)\n索引.js
\nconst functions = require("firebase-functions");\nconst admin = require("firebase-admin");\n\nadmin.initializeApp();\n\nexports.scheduledFunction = functions.pubsub\n .schedule("45 8 * * *")\n .timeZone("America/Sao_Paulo")\n .onRun(() => {\n console.log("Triggering email")\n return null;\n });\nRun Code Online (Sandbox Code Playgroud)\n部署
\n% firebase deploy --only functions \n\n=== Deploying to \'****\'...\n\ni deploying functions\nRunning command: npm --prefix "$RESOURCE_DIR" run lint\n\n> functions@ lint ****/functions\n> eslint .\n\n\xe2\x9c\x94 functions: Finished running predeploy script.\ni functions: preparing codebase default for deployment\ni functions: ensuring required API cloudfunctions.googleapis.com is enabled...\ni functions: ensuring required API cloudbuild.googleapis.com is enabled...\ni artifactregistry: ensuring required API artifactregistry.googleapis.com is enabled...\n\xe2\x9c\x94 artifactregistry: required API artifactregistry.googleapis.com is enabled\n\xe2\x9c\x94 functions: required API cloudfunctions.googleapis.com is enabled\n\xe2\x9c\x94 functions: required API cloudbuild.googleapis.com is enabled\ni functions: preparing functions directory for uploading...\ni functions: packaged ****/functions (41.84 KB) for uploading\ni functions: ensuring required API cloudscheduler.googleapis.com is enabled...\n\xe2\x9c\x94 functions: required API cloudscheduler.googleapis.com is enabled\n\xe2\x9c\x94 functions: functions folder uploaded successfully\n\nThe following functions are found in your project but do not exist in your local source code:\n listenReserveCreated(us-central1)\n\nIf you are renaming a function or changing its region, it is recommended that you create the new function first before deleting the old one to prevent event loss. For more info, visit https://firebase.google.com/docs/functions/manage-functions#modify\n\n? Would you like to proceed with deletion? Selecting no will continue the rest of the deployments. No\ni functions: updating Node.js 10 function scheduledFunction(us-central1)...\nFunction failed on loading user code. This is likely due to a bug in the user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation.\n\nFunctions deploy had errors with the following functions:\n scheduledFunction(us-central1)\ni functions: cleaning up build files...\n\nError: There was an error deploying functions\nRun Code Online (Sandbox Code Playgroud)\n日志:
\n% gcloud functions logs read scheduledFunction\nLEVEL NAME EXECUTION_ID TIME_UTC LOG\nE scheduledFunction 2023-03-17 12:36:18.077 Function cannot be initialized. Error: function terminated. Recommended action: inspect logs for termination reason. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging\n scheduledFunction csgypxon04g7 2023-03-17 12:36:17.539 Could not load the function, shutting down.\n scheduledFunction csgypxon04g7 2023-03-17 12:36:17.538 at Module._compile (internal/modules/cjs/loader.js:778:30)\n scheduledFunction csgypxon04g7 2023-03-17 12:36:17.538 at Object.<anonymous> (/workspace/node_modules/firebase-functions/lib/logger/index.js:26:17)\n scheduledFunction csgypxon04g7 2023-03-17 12:36:17.538 at require (internal/modules/cjs/helpers.js:25:18)\n scheduledFunction csgypxon04g7 2023-03-17 12:36:17.538 at Module.require (internal/modules/cjs/loader.js:692:17)\n scheduledFunction csgypxon04g7 2023-03-17 12:36:17.538 at Function.Module._load (internal/modules/cjs/loader.js:585:3)\n scheduledFunction csgypxon04g7 2023-03-17 12:36:17.538 at tryModuleLoad (internal/modules/cjs/loader.js:593:12)\n scheduledFunction csgypxon04g7 2023-03-17 12:36:17.538 at Module.load (internal/modules/cjs/loader.js:653:32)\n scheduledFunction csgypxon04g7 2023-03-17 12:36:17.538 at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)\n scheduledFunction csgypxon04g7 2023-03-17 12:36:17.538 at Module._compile (internal/modules/cjs/loader.js:778:30)\n scheduledFunction csgypxon04g7 2023-03-17 12:36:17.538 at Object.<anonymous> (/workspace/node_modules/firebase-functions/lib/common/trace.js:6:24)\n scheduledFunction csgypxon04g7 2023-03-17 12:36:17.538 Detailed stack trace: TypeError: async_hooks_1.AsyncLocalStorage is not a constructor\n scheduledFunction csgypxon04g7 2023-03-17 12:36:17.538 Is there a syntax error in your code?\n scheduledFunction csgypxon04g7 2023-03-17 12:36:17.538 Provided module can\'t be loaded.\nE scheduledFunction 2023-03-17 12:27:24.077 Function cannot be initialized. Error: function terminated. Recommended action: inspect logs for termination reason. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging\n scheduledFunction vfj9lv1lxvmm 2023-03-17 12:27:22.993 Could not load the function, shutting down.\n scheduledFunction vfj9lv1lxvmm 2023-03-17 12:27:22.992 at Module._compile (internal/modules/cjs/loader.js:778:30)\n scheduledFunction vfj9lv1lxvmm 2023-03-17 12:27:22.992 at Object.<anonymous> (/workspace/node_modules/firebase-functions/lib/logger/index.js:26:17)\n scheduledFunction vfj9lv1lxvmm 2023-03-17 12:27:22.992 at require (internal/modules/cjs/helpers.js:25:18)\nRun Code Online (Sandbox Code Playgroud)\n
当您使用过时版本的 Node.js 时,就会发生这种情况。在上面的日志中,您仍在使用 Node.js v10:
\ni functions: updating Node.js 10 function scheduledFunction(us-central1)...
\n\n确保您的服务器根据您使用的 Admin SDK 运行以下命令:
\n\n
\n- 管理 Node.js SDK \xe2\x80\x94 Node.js 14+
\n
如果更新您的 Node.js 版本后问题仍然存在,请告诉我。
\n| 归档时间: |
|
| 查看次数: |
758 次 |
| 最近记录: |