sidorares / sidorares/node-mysql2
how to appropriate close(interrupt) stream result before end event ?
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 4.4k
- Forks
- 680
- Avg merge
- 9h 7m
- Merged PRs (30d)
- 59
Description
as title, how to correctly interrupt stream results?
In mysqljs, I call .end(). that will trigger end event, then close stream
but in mysql2, TypeError: query.end is not a function
here is my code sample
// getConnection from pool
const query = conn.query('SELECT * FROM `table`')
.on('result', (aRow)=>{
// I handle one row and response to client, but if data is error or client disconnect, I need to stop res.
// thus, i call query.end();
})
.on('end', ()=>{
conn.release();
});
I'm curiosity, query is readable stream or the other? but readable stream should not have end() method
should I call destroy() or close() preferable ?
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 with the conn.query call and its result/end handlers in the supplied example, then inspect how mysql2 exposes query results and stream interruption. Reproduce the client-disconnect or row-error case and compare destroy() and close() behavior; done means identifying the supported way to stop the query and release the connection without relying on an end event.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, mysql, node.js
- Domain
- backend, database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100