sidorares / sidorares/node-mysql2

Add keepAlive option for socket

Open
#643 3 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
4.4k
Forks
680
Avg merge
9h 7m
Merged PRs (30d)
59

Description

I am using this module in conjunction with sequelize in an environment where keep-alive needs to be set on open sockets. In order to set keep-alive on the sockets I have to monkey-patch sequelize like this:

var manager = sequelize.connectionManager;
var getConnection = manager.getConnection;
manager.getConnection = function () {
    return getConnection.apply(manager, arguments).then((conn) => {
        conn.stream.setKeepAlive(true, 120000);
        return conn;
    });
};

Would it be possible to add a keepAlive option to the connection constructor? I realize API compatibility with node-mysql is a priority here, so let me know if I should file this issue over there instead.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the connection constructor and the socket exposed as conn.stream, using the Sequelize monkey-patch as the behavioral example. Trace how connection options reach socket creation, then verify that a keepAlive option enables the requested keep-alive behavior without requiring monkey-patching.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, node.js
Domain
database, networking
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.