gpt4 book ai didi

node.js - GCF Node10 部署失败 : "Function failed on loading user code. Error message: Provided code is not a loadable module."

转载 作者:搜寻专家 更新时间:2023-11-01 00:03:38 25 4
gpt4 key购买 nike

在进行了一些调整(相当大的 PR)之后,基本上将 Google Cloud Storage 连接添加到此功能,部署开始失败。不幸的是,错误消息非常不清楚,因此没有提供太多提示。在本地和测试中一切都运行良好,所以我现在有点迷失了搜索的方向。日志也不提供见解。

不幸的是,不能真正轻松地分享 PR 中的更改。最坏的情况我会恢复并从那里开始逐步进行,但这是一个乏味的过程。

部署中使用的服务帐户可以访问使用过的存储桶(带写入),但我也不认为此错误提示权限,否则我希望错误消息会更有见地。

使用的命令:

gcloud beta 函数部署 eventStreamPostEvent --runtime nodejs10 --memory 128MB --trigger-http --source ./dist --service-account $DEPLOY_SERVICE_ACCOUNT --verbosity debug

Deploying function (may take a while - up to 2 minutes)...
..............................failed.
DEBUG: (gcloud.beta.functions.deploy) OperationError: code=3, message=Function failed on loading user code. Error message: Provided code is not a loadable module.
Could not load the function, shutting down.
Traceback (most recent call last):
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/calliope/cli.py", line 985, in Execute
resources = calliope_command.Run(cli=self, args=args)
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/calliope/backend.py", line 795, in Run
resources = command_instance.Run(args)
File "/usr/lib/google-cloud-sdk/lib/surface/functions/deploy.py", line 231, in Run
enable_vpc_connector=True)
File "/usr/lib/google-cloud-sdk/lib/surface/functions/deploy.py", line 175, in _Run
return api_util.PatchFunction(function, updated_fields)
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/util.py", line 300, in CatchHTTPErrorRaiseHTTPExceptionFn
return func(*args, **kwargs)
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/util.py", line 356, in PatchFunction
operations.Wait(op, messages, client, _DEPLOY_WAIT_NOTICE)
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/operations.py", line 126, in Wait
_WaitForOperation(client, request, notice)
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/operations.py", line 101, in _WaitForOperation
sleep_ms=SLEEP_MS)
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/core/util/retry.py", line 219, in RetryOnResult
result = func(*args, **kwargs)
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/operations.py", line 65, in _GetOperationStatus
raise exceptions.FunctionsError(OperationErrorToString(op.error))
FunctionsError: OperationError: code=3, message=Function failed on loading user code. Error message: Provided code is not a loadable module.
Could not load the function, shutting down.

ERROR: (gcloud.beta.functions.deploy) OperationError: code=3, message=Function failed on loading user code. Error message: Provided code is not a loadable module.
Could not load the function, shutting down.

我希望有人知道是什么导致了这个错误。

Stackdriver 日志只显示:

 protoPayload: {
@type: "type.googleapis.com/google.cloud.audit.AuditLog"
authenticationInfo: {…}
methodName: "google.cloud.functions.v1.CloudFunctionsService.UpdateFunction"
requestMetadata: {
destinationAttributes: {…}
requestAttributes: {…}
}
resourceName: "projects/<projectName>/locations/europe-west1/functions/eventStreamPostEvent"
serviceName: "cloudfunctions.googleapis.com"
status: {
code: 3
message: "INVALID_ARGUMENT"
}
}

最佳答案

我遇到了同样的问题,消息似乎来自 here .

当你的函数的根文件夹中有多个 .js 文件和一些子文件夹时,默认情况下你需要将入口模块命名为 index.js 或 function.js。

我发现通过使用 node8 部署函数。错误信息应该更清楚...

关于node.js - GCF Node10 部署失败 : "Function failed on loading user code. Error message: Provided code is not a loadable module.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55937159/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com