-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
r.connectPool not waiting for connection/not blocking the rest. #44
Comments
I don't think rethinkdbdash blocks whole execution, more like queues up queries and then starts to return them after connection is established. |
@McSneaky running simple test:
Outputs following:
Since self-invoking functions are called immediately, i think that rethinkdbdash is waiting for connection/blocking execution after... Running same code with rethinkdb-ts will throw an error above... |
I can externalize the r.connectPool({
host: '127.0.0.1',
port: 28015,
db: 'test',
silent: true,
waitForHealthy: false // this will ignore initial pool initialization errors so you don't have to await them
});
(async function getData() {
await (r.getPoolMaster() as any).waitForHealthy(); // this will actually not do anything if the pool is healthy, and if it's not it will just wait for the first connection to be available
const result = await r.table('test').run();
console.log(JSON.stringify(result));
})(); This is actually a feature, not a bug, I wanted to know ahead of time if the pool is connecting or not, the rethinkdbdash connect doesn't tell you on initialization weather it works or not, you have to wait for the first query... this way you can initialize the app and handle it better if you have no connection to the db on start. |
// Update: I think my comment is slightly different and will make a seperate issue. |
My issue is referring to another RethinkDB library, rethinkdbdash and how the pool connection was made. My problem is that we use self-invoking/self-calling functions, and there where problem occur.
Following code work just fine, because self-invoked function is not being called before rethinkdb connection is established.
But, it's not working with rethinkdb-ts because you'll have to call it as await within async function. Putting
await r.connectPool
inside self-invoking function isn't probably a good move, because it will be called on each run.Following code will not even work, because self-invoked function is called much earlier that connection is established.
Following error will be thrown:
And there is another point i wondering about:
So, it there some way to maky it work like it was with rethinkdbdash? Block whole execution of script before db connection is established? And why it's not opening new connections as well?
Thanks!
The text was updated successfully, but these errors were encountered: