sidorares / sidorares/node-mysql2
uncatchable pool exceptions
Open
Nobody has claimed this yet.
high-priority
- Dominant language
- TypeScript
- Stars
- 4.4k
- Forks
- 680
- Avg merge
- 9h 7m
- Merged PRs (30d)
- 59
Description
If for example, a query with an undefined value is executed on a pool connection, this throws an uncatchable exception that kills the node process. This is because the exception is not happening on the calling "thread".
See line 177 in lib/pool.js
execute(sql, values, cb) {
// TODO construct execute command first here and pass it to connection.execute
// so that polymorphic arguments logic is there in one place
if (typeof values === 'function') {
cb = values;
values = [];
}
this.getConnection((err, conn) => {
if (err) {
return cb(err);
}
try {
conn.execute(sql, values, cb).once('end', () => {
conn.release();
});
} catch (e) {
conn.release();
throw e; // <------ How is this going to be caught anywhere ?
}
});
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read lib/pool.js around line 177 and trace the execute callback and connection path. Reproduce the issue with a query containing an undefined value; done means the pool error is catchable by the caller and no longer terminates the Node.js process.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mysql, node.js
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100