Vercel 通过来自 SvelteKit 应用程序的简单 GraphQL 请求“此无服务器功能已崩溃”

Koe*_*oen 5 graphql svelte vercel aws-serverless

我在初始页面加载时经常遇到看似随机的错误。我认为问题与 Vercel Serverless Functions 有关。

\n

我经常在网站本身上收到此错误:\n在此输入图像描述

\n

Vercel 的完整日志:

\n
[GET] /\n14:54:19:39\n2022-07-21T12:54:19.426Z    3a175b6b-396b-45d5-b1a1-46072201cd6a    ERROR   Unhandled Promise Rejection     \n{"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"FetchError: request to \nhttps://api-eu-central-1.graphcms.com/v2/cl2k6hi1809a401xk4hd3h5zj/master failed, reason: \nClient network socket disconnected before secure TLS connection was \nestablished","reason":{"errorType":"FetchError","errorMessage":"request to https://api-\neu-central-1.graphcms.com/v2/cl2k6hi1809a401xk4hd3h5zj/master failed, reason: Client \nnetwork socket disconnected before secure TLS connection was \nestablished","code":"ECONNRESET","message":"request to https://api-eu-central-\n1.graphcms.com/v2/cl2k6hi1809a401xk4hd3h5zj/master failed, reason: Client network socket \ndisconnected before secure TLS connection was \nestablished","type":"system","errno":"ECONNRESET","stack":["FetchError: request to \nhttps://api-eu-central-1.graphcms.com/v2/cl2k6hi1809a401xk4hd3h5zj/master failed, reason: \nClient network socket disconnected before secure TLS connection was established","    at \nClientRequest.<anonymous> (/var/task/index.js:7892:18)","    at ClientRequest.emit \n(node:events:527:28)","    at TLSSocket.socketErrorListener (node:_http_client:454:9)","    \nat TLSSocket.emit (node:events:527:28)","    at emitErrorNT (node:internal/streams\n/destroy:157:8)","    at emitErrorCloseNT (node:internal/streams/destroy:122:3)","    at \nprocessTicksAndRejections (node:internal/process/task_queues:83:21)"]},"promise":\n{},"stack":["Runtime.UnhandledPromiseRejection: FetchError: request to https://api-eu-\ncentral-1.graphcms.com/v2/cl2k6hi1809a401xk4hd3h5zj/master failed, reason: Client network \nsocket disconnected before secure TLS connection was established","    at process.\n<anonymous> (file:///var/runtime/index.mjs:775:15)","    at process.emit \n(node:events:539:35)","    at emit (node:internal/process/promises:140:20)","    at \nprocessPromiseRejections (node:internal/process/promises:274:27)","    at \nprocessTicksAndRejections (node:internal/process/task_queues:97:32)"]}[ERROR] \n[1658408059427] LAMBDA_RUNTIME Failed to post handler success response. Http response \ncode: 400.RequestId: 2a0597b4-6684-4f2a-a724-2333b4f9332d Error: Runtime exited with \nerror: exit status 128Runtime.ExitError\n
Run Code Online (Sandbox Code Playgroud)\n

SvelteKit 端点的示例代码:

\n
[GET] /\n14:54:19:39\n2022-07-21T12:54:19.426Z    3a175b6b-396b-45d5-b1a1-46072201cd6a    ERROR   Unhandled Promise Rejection     \n{"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"FetchError: request to \nhttps://api-eu-central-1.graphcms.com/v2/cl2k6hi1809a401xk4hd3h5zj/master failed, reason: \nClient network socket disconnected before secure TLS connection was \nestablished","reason":{"errorType":"FetchError","errorMessage":"request to https://api-\neu-central-1.graphcms.com/v2/cl2k6hi1809a401xk4hd3h5zj/master failed, reason: Client \nnetwork socket disconnected before secure TLS connection was \nestablished","code":"ECONNRESET","message":"request to https://api-eu-central-\n1.graphcms.com/v2/cl2k6hi1809a401xk4hd3h5zj/master failed, reason: Client network socket \ndisconnected before secure TLS connection was \nestablished","type":"system","errno":"ECONNRESET","stack":["FetchError: request to \nhttps://api-eu-central-1.graphcms.com/v2/cl2k6hi1809a401xk4hd3h5zj/master failed, reason: \nClient network socket disconnected before secure TLS connection was established","    at \nClientRequest.<anonymous> (/var/task/index.js:7892:18)","    at ClientRequest.emit \n(node:events:527:28)","    at TLSSocket.socketErrorListener (node:_http_client:454:9)","    \nat TLSSocket.emit (node:events:527:28)","    at emitErrorNT (node:internal/streams\n/destroy:157:8)","    at emitErrorCloseNT (node:internal/streams/destroy:122:3)","    at \nprocessTicksAndRejections (node:internal/process/task_queues:83:21)"]},"promise":\n{},"stack":["Runtime.UnhandledPromiseRejection: FetchError: request to https://api-eu-\ncentral-1.graphcms.com/v2/cl2k6hi1809a401xk4hd3h5zj/master failed, reason: Client network \nsocket disconnected before secure TLS connection was established","    at process.\n<anonymous> (file:///var/runtime/index.mjs:775:15)","    at process.emit \n(node:events:539:35)","    at emit (node:internal/process/promises:140:20)","    at \nprocessPromiseRejections (node:internal/process/promises:274:27)","    at \nprocessTicksAndRejections (node:internal/process/task_queues:97:32)"]}[ERROR] \n[1658408059427] LAMBDA_RUNTIME Failed to post handler success response. Http response \ncode: 400.RequestId: 2a0597b4-6684-4f2a-a724-2333b4f9332d Error: Runtime exited with \nerror: exit status 128Runtime.ExitError\n
Run Code Online (Sandbox Code Playgroud)\n

现在,其他人似乎也有类似的问题:

\n\n

尤其是最后一个链接,看起来问题的根源在于 AWS Lambda。我并不期望有灵丹妙药,但我确实想确保问题确实如我所想(而不是我的代码中的错误)。

\n

有没有人找到任何解决方法?如何最大限度地减少这些功能崩溃的可能性?

\n

小智 0

我不得不添加index.js进来vercel.json。请参阅此链接了解更多信息。