sidorares / sidorares/node-mysql2
When mysqld is not running an uncatchable timeout exception is raised
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 4.4k
- Forks
- 680
- Avg merge
- 9h 7m
- Merged PRs (30d)
- 59
Description
If mysqld is not running and I try to open a connection to a database then I get an exception thrown:
{ Error: Connection lost: The server closed the connection.
message: 'Connection lost: The server closed the connection.',
code: 'PROTOCOL_CONNECTION_LOST',
errno: undefined,
sqlState: undefined }
which I catch and handle. A few seconds later I also get a timeout exception thrown:
Error: connect ETIMEDOUT
at Connection._handleTimeoutError (/opt/ibm/services/node_modules/mysql2/lib/connection.js:171:17)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10)
errorno: 'ETIMEDOUT',
code: 'ETIMEDOUT',
syscall: 'connect',
fatal: true }
which I cannot handle as my code handling the mysql connection has already caught the exception and exited. Well I could handle it in my global exception handler, but I don't think I should need to.
Please see https://github.com/sidorares/node-mysql2/pull/950 for a proposed solution which works for me.
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 reviewing the proposed solution in pull request #950 and the timeout path at lib/connection.js:171. Reproduce the behavior with mysqld stopped, then verify that the timeout exception can be handled through the connection's normal error handling rather than becoming an uncaught exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mysql, node.js, typescript
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 20/100