Promises never get resolved in specific cases
See original GitHub issueIssue type:
[x] bug report [ ] feature request [ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql
/ mariadb
[ ] oracle
[x] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[ ] latest
[x] @next
[ ] 0.x.x
(or put your version here)
Steps to reproduce or a small repository showing the problem:
Sometimes promises just never resolve. At first I thought it might be related with running scripts with ts-node
, however even when using pure JS the issue is the same.
The freeze always happens when I try to perform a query after another query was performed without closing the connection. Here closing and re-connecting seems to avoid the bug, however I had another case where I tried saving an entity to a repository after performing a raw query and it also froze on the await repository.save(...)
method, re-connecting did not fix it.
Here’s a code snippet:
const createConnection = require("typeorm").createConnection;
(async () => {
const con = await createConnection();
await con.createQueryRunner().query(`SELECT 1 as foo`);
// re-connecting would work here...
// await con.close();
// await con.connect();
await con.createQueryRunner().query(`SELECT 1 as foo`);
console.log(1);
await con.close(); // freezes here
console.log(2); // this is never reached
})();
The actual contents of the raw query do not seem to matter, it happens every time. The problem is probably related to raw queries since the problem didn’t happen with repositories (until doing a raw query once, after that it does).
Also tried it without await
by using .then(...)
callbacks, same outcome.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:5 (1 by maintainers)
Top GitHub Comments
This still happens on 0.2.34
I can’t replicate it. Can you open a new issue with info on how you’re replicating this issue