jeremydaly / data-api-client

A "DocumentClient" for the Amazon Aurora Serverless Data API
MIT License
439 stars 61 forks source link

Client timeout configuration #68

Open martinpllu opened 3 years ago

martinpllu commented 3 years ago

Possibly related to #40, which was closed.

I'd like to be able to specify a timeout on the client, so that I can detect slow responses (usually due to the DB resuming after auto-pause) before my Lambda function times out, and handle them appropriately.

I've tried passing through RDSDataService timeout properties via options but they have no effect.

require('data-api-client')({
...
options: {
    httpOptions: {
        // Low values for test purposes
        connectTimeout: 10,
        timeout: 10
    }
})}

This isn't surprising as the socket connection will be made promptly, even if the database query is slow.

Is there anything else that I can try? Appreciate that this is probably a limitation of the underlying client/service rather than your (extremely useful) wrapper.

martinpllu commented 3 years ago

I suppose that one approach would be to apply a timeout to the promise in application code, e.g. https://italonascimento.github.io/applying-a-timeout-to-your-promises

eyabmohero commented 3 years ago

Hello Im having timeout connection issue in 3 seconds , using Lambda any idea ?