9

so i'm having this problem on a nuxt implementation with vercel, at random moments the site doesn't load and throws a 502 http error this is the stacktrace of 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

So the error it's about a connection with the api, for what i found this is a Node error but my api is developed on Laravel so i'm really lost Thanks for the help

juan
  • 91
  • 3
  • 2
    Running into this with Vercel and `googleapis` right now too. Any help would be appreciated. – Ashkay Nov 24 '20 at 02:07
  • 1
    Having the same issue – K. D. Mar 08 '21 at 13:49
  • 2
    Having the same issue with a NuxtJS project on Vercel. Vercel use AWS Lambda and many people are reporting the issue here: https://github.com/aws/aws-sdk-js/issues/3591 – brad Jun 05 '21 at 00:04

1 Answers1

2

I ran into this issue (with a Next.js project on Vercel) and fixed it. I was calling an external API but forgot to await one of the handlers, so the Lambda eventually stopped waiting for the API call response once my code finished running.

Bathlamos
  • 312
  • 4
  • 10
  • Can you please give more details how did you fix it. Than kyou – Kiril Lukiyan Oct 13 '22 at 12:55
  • 1
    My situation might be different than yours. In mine, the Nextjs API function contained a call to an external API, i.e. a network request. But as I didn't add 'await' in front of it, the Nextjs API function finished execution while the call to the external API was pending. Vercel detected that the execution completed and likely killed the lambda executing it, which put a premature end to the external API call that was still pending. The moral of the story is simply to make sure to await all asynchronous code. – Bathlamos Oct 14 '22 at 13:08
  • Thank you. You are right. I was desperately looking for a solution. Asking for any clue. Finally found it in a totally unrelated topic discussion. I had simply to replace created event with mounted. – Kiril Lukiyan Oct 16 '22 at 06:59