rethinkdb-ts icon indicating copy to clipboard operation
rethinkdb-ts copied to clipboard

What happens on connection error ?

Open atassis opened this issue 6 years ago • 2 comments

If we are not making any queries for a long time, we can meet a RethinkDBError with type CONNECTION. Why the library is not handling such a case by itselves? As well there is no option to set minimum of existing connections at a time, so we have to write a wrapper above .run() which checks if connection error is thrown or not. Exact message of error is "The connection was closed before the query could be completed". Node v12.13.1 Package version 2.4.0-rc.16 Any other needed information can be provided

atassis avatar Dec 17 '19 11:12 atassis

of course there is, you can set a connection pool, buffer is the min number of connections:

r.connectPool({
  db?: string; // default 'test'
  user?: string; // default 'admin'
  password?: string; // default ''
  discovery?: boolean; // default false
  pool?: boolean; // default true
  buffer?: number; // default = number of servers
  max?: number; // default = number of servers
  timeout?: number; // default = 20
  pingInterval?: number; // default -1
  timeoutError?: number; // default = 1000
  timeoutGb?: number; // default = 60*60*1000
  maxExponent?: number; // default 6
  silent?: boolean; // default = false
  log?: (message: string) => any; // default undefined;
  [other: string]: any;
})

ronzeidman avatar Dec 19 '19 22:12 ronzeidman

never encountered that kind of error before but I'm guessing if you set a ping interval you can avoid it, ping interval is in milliseconds and it sends a ping to all open connections for every interval amount of time

ronzeidman avatar Dec 19 '19 22:12 ronzeidman