Add support for timeouts
maheshoml opened this issue · 1 comments
Currently, no function which makes API request(s) have support for timeout leading to a clogged event loop for clients until the gateway itself sends a 504 Gateway Timeout (which understandably is pretty high for most use cases.)
Ideally, clients should be able to specify the maximum timeout they are willing to tolerate when calling functions from the library which make API requests.
I was waiting on cancelable promises before committing to timeouts in this SDK. I also didn't want to force promises on users as this SDK is intended to be used from a browser as well as node, meaning a minimum of a promise polyfill, and potentially a fetch polyfill if we wanted to do it "properly". Adding them would also bring the gzipped size of the SDK up to 5.5KB
from 1.7KB
, more than tripling for no functional benedit.
Promisifying the current callback API is trivial, and adding timeouts on top of that is also very easy.
If we get more requests for timeouts built into the SDK then we can revisit but we haven't seen a need for it yet.
Feel free to reply, open to feedback!