Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TLS connection errors sometimes occur #524

Closed
mongolyy opened this issue Dec 4, 2023 · 1 comment · Fixed by #552
Closed

TLS connection errors sometimes occur #524

mongolyy opened this issue Dec 4, 2023 · 1 comment · Fixed by #552

Comments

@mongolyy
Copy link

mongolyy commented Dec 4, 2023

I am using vercel and sending the request to algolia via vercel.

When I use search-instights.js I get the following error and cannot send a click event.
It does not occur every time, but once every few times.
Also, this does not occur when running at local.

2023-12-04T15:48:24.883Z	625e31bf-bc53-49fb-8835-ff936d6e5078	ERROR	Error: Client network socket disconnected before secure TLS connection was established
    at connResetException (node:internal/errors:720:14)
    at TLSSocket.onConnectEnd (node:_tls_wrap:1655:19)
    at TLSSocket.emit (node:events:529:35)
    at endReadableNT (node:internal/streams/readable:1368:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  code: 'ECONNRESET',
  path: null,
  host: 'insights.algolia.io',
  port: 443,
  localAddress: undefined
}
2023-12-04T15:48:24.884Z	625e31bf-bc53-49fb-8835-ff936d6e5078	ERROR	Unhandled Promise Rejection 
{
   "errorType":"Runtime.UnhandledPromiseRejection",
   "errorMessage":"Error: Client network socket disconnected before secure TLS connection was established",
   "reason":{
      "errorType":"Error",
      "errorMessage":"Client network socket disconnected before secure TLS connection was established",
      "code":"ECONNRESET",
      "path":null,
      "host":"insights.algolia.io",
      "port":443,
      "stack":[
         "Error: Client network socket disconnected before secure TLS connection was established",
         "    at connResetException (node:internal/errors:720:14)",
         "    at TLSSocket.onConnectEnd (node:_tls_wrap:1655:19)",
         "    at TLSSocket.emit (node:events:529:35)",
         "    at endReadableNT (node:internal/streams/readable:1368:12)",
         "    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)"
      ]
   },
   "promise":{
      
   },
   "stack":[
      "Runtime.UnhandledPromiseRejection: Error: Client network socket disconnected before secure TLS connection was established",
      "    at process.<anonymous> (file:///var/runtime/index.mjs:1276:17)",
      "    at process.emit (node:events:529:35)",
      "    at emit (node:internal/process/promises:149:20)",
      "    at processPromiseRejections (node:internal/process/promises:283:27)",
      "    at process.processTicksAndRejections (node:internal/process/task_queues:96:32)"
   ]
}
[ERROR] [1701704904888] LAMBDA_RUNTIME Failed to post handler success response. Http response code: 400.
Error: Runtime exited with error: exit status 128
Runtime.ExitError

Here is the code.
https://github.com/mongolyy/next-with-algolia-app

Since Vercel is running on Lambda and there was a LAMBDA_RUNTIME error message in this log as well, I believe the following issue may be related.
aws/aws-sdk-js#3591
I think I might need to await for the execution of some asynchronous function, but I couldn't figure out how to do it.

Any suggestion?

@wwalser
Copy link

wwalser commented Aug 23, 2024

Thanks for the report and patience while we resolved. The problem here is that the main interface to this library doesn't return anything.

const isAnythingReturned = aa('doAThing', {argument1: 1234});
// prints `undefined`
console.log(isAnythingReturned);

This means that async functions within the interface were impossible to await (or chain using promises).

// not possible because no promise is returned
await aa('asyncThing', {argument1: 1234});

This is fixed by #552 as the main aa interface now returns. Promises and async/await should function as expected with versions >2.17.0 of the lib.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants