-
Notifications
You must be signed in to change notification settings - Fork 639
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
Need to explicit destroy knex in order to stop the script #534
Comments
Hi! I use Have you tried setting the minimum pool size to zero? |
@Kostanos As food for thought, in my own mocha tests, I leverage the
It's a little bit "hacky" but it works fine and I think is safe enough for my scenario. |
I have never had to kill the process, nor have I ever had problems with mocha tests not finishing. I think there is something "wrong" with your setups. Check out objection's tests. They have no such problem. |
Just tried with Thank you for killing suggestion, it works, at least now test doesn't consume extra actually >20 seconds, as I see in pipeline. BTW. the draining of knex with DEBUG=*
I'm checking other possible scenarios, I have pg-restify server, which I also put down with:
But the issue only happens when I run test that uses ModelBase I showed above. In tests where ModelBase is not used, the script exists fast. |
I'm pretty sure this has nothing to do with objection, but just to make sure, could you create a small standalone project that reproduces this? I'm not able to reproduce this. |
Maybe you have transactions that are never committed or rolled back? Those keep a connection alive. |
Will try later about small project. No pending transactions for sure, checked it. The reason why I pointed to objection+knex, is because if I don't destroy knex with knex.destroy(), the test never ends at all, and with DEBUG=* I see knex keeps pinging connection in pool. Anyway, for now I'm ok with process.exit, will go forward with next tasks. If you prefer, we can close this task until I have more data to reproduce it. Thank you for your time and help! |
This can easily be an issue in knex. Objection doesn't start queries or do anything funky without the user explicitly telling it. I'll close this now, but I'd like to know what caused this if you get to the bottom of this. |
For me explicitly setting |
@tmaxim-gpsw No idea. I have never had that issue. Knex github or gitter is probably a better place to get the answer for this. |
I'm not sure if related, but default behaviour changed in mocha https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#default-behavior That it does not force exit after tests has been ran, so I suppose it will wait until generic-pool evicts idle connections before exitting...
I would go for explicitly destroying knex after tests has been complete. |
@elhigu The issue seems to be that |
Uh right... I missed that. |
Seeing the same problem. It was fixed by using |
add |
I've added
and here how I close it:
BTW. it only happens if I run at least one query. if I don't run any queries, no timeout on tests (the connections closes without issues) |
I don't really know what the implications are of this, but I saw it suggested (here)[Vincit/objection.js#534] and it worked and doesn't require manually running `db.destroy()` after each test.
* Set timeout for test pool I don't really know what the implications are of this, but I saw it suggested (here)[Vincit/objection.js#534] and it worked and doesn't require manually running `db.destroy()` after each test. * Lint pass * Skipping app test I will go back and test these later.
I still have the issue with |
When trying to work with the DB in the tests we were getting ``` Jest did not exit one second after the test run has completed. This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue. ``` Googling led us to [Having trouble running Jest, unhandled Promises](Vincit/objection.js#1015) and [Need to explicit destroy knex in order to stop the script](Vincit/objection.js#534). The second issue included a comment that setting the pool min size to 0 and idleTimeoutMillis to 500 would solve the problem. We tried it and it worked!
When trying to work with the DB in the tests we were getting ``` Jest did not exit one second after the test run has completed. This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue. ``` Googling led us to [Having trouble running Jest, unhandled Promises](Vincit/objection.js#1015) and [Need to explicit destroy knex in order to stop the script](Vincit/objection.js#534). The second issue included a comment that setting the pool min size to 0 and idleTimeoutMillis to 500 would solve the problem. We tried it and it worked!
When trying to work with the DB in the tests we were getting ``` Jest did not exit one second after the test run has completed. This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue. ``` Googling led us to [Having trouble running Jest, unhandled Promises](Vincit/objection.js#1015) and [Need to explicit destroy knex in order to stop the script](Vincit/objection.js#534). The second issue included a comment that setting the pool min size to 0 and idleTimeoutMillis to 500 would solve the problem. We tried it and it worked!
When trying to work with the DB in the tests we were getting ``` Jest did not exit one second after the test run has completed. This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue. ``` Googling led us to [Having trouble running Jest, unhandled Promises](Vincit/objection.js#1015) and [Need to explicit destroy knex in order to stop the script](Vincit/objection.js#534). The second issue included a comment that setting the pool min size to 0 and idleTimeoutMillis to 500 would solve the problem. We tried it and it worked!
Hi, I initialize Model this way:
The problem I have is when I run tests with mocha, mocha never ends until I run:
And even if I run it, mocha keep waiting for extra 5-10 seconds, and after actually ends.
Which makes me believe, that Objection or knex still have some process running to keep pool connections alive.
Any suggestions how could I cut this "waiting" time in mocha?
The text was updated successfully, but these errors were encountered: