所以我有一个在 Lambda 中运行的无服务器 Express 应用程序。一个请求(响应大小约为 800KB)不断返回
LAMBDA_RUNTIME Failed to post handler success response. Http response code: 413.
错误。
我认为这可能是由于某些内部逻辑超时,并添加了日志,并且所有获取和处理最多需要 6 秒,但 lamdba 仍然返回此错误。
这些是响应标头
x-amz-cf-pop: YTO50-C3
x-amzn-errortype: InternalServerErrorException
x-amzn-requestid: f291230-342-4324-324-cb7df188944c
x-cache: Error from cloudfront
响应大小绝对不会太大,我返回带有正确数据的响应,日志中没有抛出任何错误。知道为什么会发生这种情况吗?另外关于如何调试这个问题有什么建议吗?当然,一切都可以在本地运行,但是有没有办法让我调试实际的 lambda?我添加的日志表明整个过程已完成,但不知何故返回了错误。
更新了我的 serverless.yml 配置
service: my-service
variablesResolutionMode: 20210326
useDotenv: true
custom:
serverless-offline:
useChildProcesses: true
webpack:
webpackConfig: ./webpack.config.js
packager: "yarn"
includeModules: true
prune:
automatic: true
includeLayers: true
number: 3
customDomain:
domainName: "abc.com"
basePath: "val"
stage: ${someval}
createRoute53Record: true
plugins:
- serverless-domain-manager
- serverless-webpack
- serverless-prune-plugin
- serverless-webpack-prisma
- serverless-offline
provider:
lambdaHashingVersion: "20201221"
name: aws
runtime: nodejs14.x
region: us-east-1
timeout: 30
apiGateway:
minimumCompressionSize: 1024
iamRoleStatements:
- Effect: Allow
Action: ssm:Get*
Resource:
- "abc/${opt:stage}/backend/*"
- "abc/${opt:stage}/services/*"
- Effect: Allow
Action: kms:Decrypt
Resource: "*"
- Effect: "Allow"
Action: s3:PutObject
Resource: "abc/*"
- Effect: "Allow"
Action:
- sns:Publish
Resource: "*"
environment:
- myvars: 'abc'
functions:
graphql:
handler: src/index.graphqlHandler
events:
- http:
path: /graphql
method: options
- http:
path: /graphql
method: get
- http:
path: /graphql
method: post
此错误通常是由于达到了响应负载的 Lambda 限制。
目前,AWS Lambda 对以下调用负载有硬性限制:
根据文档: https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html
请记住,这是一个硬性限制,无法增加。
目前(2022年),如果您需要超过此限制,您将有我能想到的两种选择