Skip to content

Error: Cannot enqueue Handshake after already enqueuing a Handshake. #1213

@anonprophet

Description

@anonprophet
function reloadQuestion() {
    var obj = {};
    connection.connect();
    connection.query("SELECT * FROM quiz", function (err, rows, fields) {
        if (err) throw err;
        for (var i = 0; i < rows.length; i++) {
            var row = rows[i];
            obj = {"id":row.id, "question":row.question, "answers":row.answers.split(", ")};
            f100.push(obj);
            arr.push(i);
        };
        shuffleArray(arr);
        newQuestion();
    });
    connection.end();
}

reloadQuestion();

its work fine, then when after a condition when try to call reloadQuestion again its got error

Error: Cannot enqueue Handshake after already enqueuing a Handshake.
    at Protocol._validateEnqueue (/home/bot/node_modules/mysql/lib/protocol/Protocol.js:202:16)
    at Protocol._enqueue (/home/bot/node_modules/mysql/lib/protocol/Protocol.js:129:13)
    at Protocol.handshake (/home/bot/node_modules/mysql/lib/protocol/Protocol.js:52:41)
    at Connection.connect (/home/bot/node_modules/mysql/lib/Connection.js:123:18)
    at reloadQuestion (/home/bot/f100.js:56:13)
    at null._onTimeout (/home/bot/f100.js:80:8)
    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)

already try to remove connection.end(); but the problem still

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions