sidorares / sidorares/node-mysql2
warn / error when promise wrapper functions are used with callback
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 4.4k
- Forks
- 680
- Avg merge
- 9h 7m
- Merged PRs (30d)
- 59
Description
Looks like it's a common mistake, we should warn ( or maybe throw an error when promisified api method is used with a call back )
https://teratail.com/questions/118317
const job = async () => {
const conn = await pool.getConnection();
await conn.query('SELECT * FROM hoge_1', (err, rows, fields) => {
if (err) throw err;
console.log(rows);
});
await conn.query('SELECT * FROM hoge_2', (err, rows, fields) => {
conn.release();
if (err) throw err;
console.log(rows);
});
};
await job();
await pool.end();
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
Start by locating the promise wrapper used by conn.query and the callback-handling path shown in the example. Check how pool.getConnection and the promise API distinguish callback usage, then add coverage for the selected warning or error behavior and verify the example no longer passes silently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mysql, node.js, typescript
- Domain
- backend, database
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100