Skip to content
This repository has been archived by the owner on Dec 2, 2018. It is now read-only.

Connection Closed Issue #16

Open
benjamin-wss opened this issue Jun 7, 2017 · 0 comments
Open

Connection Closed Issue #16

benjamin-wss opened this issue Jun 7, 2017 · 0 comments

Comments

@benjamin-wss
Copy link

I found that connect-mssql tends to have connection closed issues at random.

I had the good fortune of finding out that for reasons I have yet to comprehend, in the _ready prototype function, the connection was closed.

My workaround was to do the following:

mssql_session_store.__proto__._ready = function (callback) {
    if (this.connection.connected) {
        return callback.call(this);
    }

    if (this.connection.connecting) {
        return this.connection.once('connect', callback.bind(this));
    }

    try {
        const current_instance = this;

        this.connection.connect().then(function () {
            return callback.call(current_instance);
        }).catch(error => {
            console.error('Unable to reopen closed connection', error);
            return callback.call(this, new Error(error.message));
        });
    } catch (error) {
        console.error('Unable to reopen closed connection', error);
        return callback.call(this, new Error("Connection is closed."));
    }
}

The issue hasn't cropped up again but that is not saying much as they happen at random. Can you verify if this is indeed a proper workaround?

benvium added a commit to calvium/connect-mssql that referenced this issue Apr 3, 2018
benvium added a commit to calvium/connect-mssql that referenced this issue Apr 3, 2018
bump version 1.60 and update URL and readme
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant