【发布时间】:2020-11-19 05:16:28
【问题描述】:
我使用serverless-next.js 包将我的next.js 应用程序部署到aws。
当我尝试将一个大文件 (~1MB) 发布到 api 路由时,我收到了 503 响应代码。
完整回复内容:
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The request could not be satisfied</TITLE>
</HEAD><BODY>
<H1>503 ERROR</H1>
<H2>The request could not be satisfied.</H2>
<HR noshade size="1px">
The Lambda function associated with the CloudFront distribution is invalid or doesn't have the required permissions.
We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
<BR clear="all">
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.
<BR clear="all">
<HR noshade size="1px">
<PRE>
Generated by cloudfront (CloudFront)
Request ID: X
</PRE>
<ADDRESS>
</ADDRESS>
</BODY></HTML>
CloudWatch 日志显示:
{
"errorType": "Error",
"errorMessage": "Cannot call write after a stream was destroyed",
"code": "ERR_STREAM_DESTROYED",
"stack": [
"Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed",
" at WriteStream._write (internal/fs/streams.js:379:33)",
" at WriteStream.<anonymous> (internal/fs/streams.js:375:12)",
" at Object.onceWrapper (events.js:422:26)",
" at WriteStream.emit (events.js:327:22)",
" at WriteStream.EventEmitter.emit (domain.js:483:12)",
" at internal/fs/streams.js:366:10",
" at FSReqCallback.oncomplete (fs.js:156:23)"
]
}
我正在使用 formidable 来解析请求的正文。它适用于较小的文件大小。
我能做什么? 1MB 不算大文件。
在开发中,即使是 10MB 的文件,一切都可以正常工作,但在 AWS lambda@edge 中却不行
【问题讨论】:
标签: aws-lambda next.js serverless