#community-help

Timeout Issues with NodeJS Bindings for Typesense and Axios

TLDR Todd reported intermittent timeout errors when using NodeJS bindings for Typesense with the Axios library. Jason tried to troubleshoot the issue, but the source of the 2s timeout remains unidentified.

Powered by Struct AI
Oct 20, 2022 (14 months ago)
Todd
Photo of md5-cccf0b87668408fef09dd77e1948fced
Todd
09:35 PM
Hi, we’re using the NodeJS bindings for typesense, and we’re possibly seeing some timeout issues from the Axios library? We’re getting this message intermittently from our server:


Request #1666300760400: Request to Node 0 failed due to “ECONNABORTED timeout of 2000ms exceeded”

Request #1666300760400: Sleeping for 0.1s and then retrying request...

Request #1666300760512: Request to Node 0 failed due to “ECONNABORTED timeout of 2000ms exceeded”

Request #1666300760512: Sleeping for 0.1s and then retrying request...

Request #1666300760400: Request to Node 0 failed due to “ECONNABORTED timeout of 2000ms exceeded”

Request #1666300760400: Sleeping for 0.1s and then retrying request...

Debug: handler, error
Error: timeout of 2000ms exceeded
at createError (/opt/xyz/node_modules/typesense/node_modules/axios/lib/core/createError.js:16:15)
at RedirectableRequest.handleRequestTimeout (/opt/xyz/node_modules/typesense/node_modules/axios/lib/adapters/http.js:369:16)
at RedirectableRequest.emit (node:events:513:28)
at Timeout.<anonymous> (/opt/xyz/node_modules/follow-redirects/index.js:169:12)
at listOnTimeout (node:internal/timers:559:17)
at processTimers (node:internal/timers:502:7)
Debug: internal, error
Error: timeout of 2000ms exceeded
at createError (/opt/xyz/node_modules/typesense/node_modules/axios/lib/core/createError.js:16:15)
at RedirectableRequest.handleRequestTimeout (/opt/xyz/node_modules/typesense/node_modules/axios/lib/adapters/http.js:369:16)
at RedirectableRequest.emit (node:events:513:28)
at Timeout.<anonymous> (/opt/xyz/node_modules/follow-redirects/index.js:169:12)
at listOnTimeout (node:internal/timers:559:17)
at processTimers (node:internal/timers:502:7)
Request #1666300760512: Request to Node 0 failed due to “ECONNABORTED timeout of 2000ms exceeded”
```
Oct 21, 2022 (14 months ago)
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
12:34 AM
Todd
Photo of md5-cccf0b87668408fef09dd77e1948fced
Todd
05:30 PM
Jason - If your default is 5, why is it timing out at 2 seconds?
05:32
Todd
05:32 PM
Is there an environment variable it might be reading from? We don’t pass any timeout options into our constructor
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
05:36 PM
Do you use axios directly in your project? If so, I wonder if you have global axios timeout configured which is taking precedence
Todd
Photo of md5-cccf0b87668408fef09dd77e1948fced
Todd
05:37 PM
not directly, but perhaps a module (or a module of a module, etc)
05:38
Todd
05:38 PM
it looks like we use assembly ai for some transcription related tasks, and they also consume axios?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
05:38 PM
May be they’ve configured a global axios timeout?
Todd
Photo of md5-cccf0b87668408fef09dd77e1948fced
Todd
05:47 PM
Scanning their source code, they do not appear to.
06:10
Todd
06:10 PM
It’s a pretty small codebase, 200 lines in total:

https://github.com/PhillipChaffee/assemblyai-node-sdk/blob/master/src/assembly-client.ts

I see 3 invocations of the string timeout, none of which remotely resemble the global timeout stuff
06:12
Todd
06:12 PM
Those are the only two packages that ping via npm ls. I’m pretty stumped by what the source of this could be.
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
06:29 PM
This is where we set the axios timeout: https://github.com/typesense/typesense-js/blob/2d20f926dc6e38d802fe8d9c703c0040f5710b9a/src/Typesense/ApiCall.ts#L128

Nothing fancy in there… The axios timeout param is documented here: https://axios-http.com/docs/instance
06:30
Jason
06:30 PM
So not sure where it’s picking up 2s from - that’s not the default in axios or in typesense-js