neumino / rethinkdbdash

An advanced Node.js driver for RethinkDB with a connection pool, support for streams etc.
MIT License
848 stars 108 forks source link

Expected behavior of r.connect and connection pool #330

Closed lirantal closed 7 years ago

lirantal commented 7 years ago

What is the expected behavior when one does r.connect() with regards to server/port configuration?

If a single instance of host/port is provided such as:

r.connect({ 
  pool: true,
  host: 'localhost',
  port: 1234
})

Then r.connect() connects but also seems to initialize a connection pool based on these settings. So far so good.

However, if r.connect() is served with the expected servers pool object that rethinkdbdash uses such as:

r.connect({
  pool: true,
  servers: [{
    host: 'localhost',
    port: 1234
  ]}
})

Then the 1st connection is initialized with defaults (localhost, 28015) because no host/port are provided, yet the rest of the connection pool initializes correctly.

While that's probably not much of a bug by itself it appears as an inconsistent behavior which causes confusion with regards to the options object provided and the usage of r.connect().

neumino commented 7 years ago

r.connect just returns a connection, there's no pool involved.

If you have a pool, it's because you initialized the driver with pool: true (which is also the default value)

lirantal commented 7 years ago

@neumino if you debug the connection that gets created when you pass pool: true you'll see that there's also a connection initialized for the 'single server' address