Vercel 无服务器功能与 nuxtjs ECONNRESET 客户端网络套接字在建立安全 TLS 连接之前断开连接

jua*_*uan 9 node.js vue.js nuxt.js vercel

所以我在使用 vercel 的 nuxt 实现上遇到了这个问题,随机时刻该网站无法加载并抛出 502 http 错误,这是 vercel 的堆栈跟踪:

ERROR   Unhandled Promise Rejection     {"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"FetchError: request to {api_url} failed, reason: Client network socket disconnected before secure TLS connection was established","reason":{"errorType":"FetchError","errorMessage":"request to {api_url} failed, reason: Client network socket disconnected before secure TLS connection was established","code":"ECONNRESET","message":"request to {api_url} failed, reason: Client network socket disconnected before secure TLS connection was established","type":"system","errno":"ECONNRESET","stack":["FetchError: request to {api_url} failed, reason: Client network socket disconnected before secure TLS connection was established","    at ClientRequest.<anonymous> (server.js:16011:11)","    at ClientRequest.emit (events.js:315:20)","    at ClientRequest.EventEmitter.emit (domain.js:483:12)","    at TLSSocket.socketErrorListener (_http_client.js:426:9)","    at TLSSocket.emit (events.js:315:20)","    at TLSSocket.EventEmitter.emit (domain.js:483:12)","    at emitErrorNT (internal/streams/destroy.js:92:8)","    at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)","    at processTicksAndRejections (internal/process/task_queues.js:84:21)"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: FetchError: request to {api_url} failed, reason: Client network socket disconnected before secure TLS connection was established","    at process.<anonymous> (/var/runtime/index.js:35:15)","    at process.emit (events.js:327:22)","    at process.EventEmitter.emit (domain.js:483:12)","    at processEmit [as emit] (/var/task/node_modules/signal-exit/index.js:161:32)","    at processPromiseRejections (internal/process/promises.js:209:33)","    at processTicksAndRejections (internal/process/task_queues.js:98:32)"]}
    Unknown application error occurred
Run Code Online (Sandbox Code Playgroud)

所以错误是关于与 api 的连接,因为我发现这是一个 Node 错误,但我的 api 是在 Laravel 上开发的,所以我真的迷失了,谢谢你的帮助

Bat*_*mos 3

我遇到了这个问题(在 Vercel 上有一个 Next.js 项目)并修复了它。我正在调用外部 API,但忘记等待其中一个处理程序,因此一旦我的代码运行完毕,Lambda 最终停止等待 API 调用响应。