Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: cb is not a function #60

Open
grayvity opened this issue Oct 29, 2019 · 2 comments
Open

TypeError: cb is not a function #60

grayvity opened this issue Oct 29, 2019 · 2 comments

Comments

@grayvity
Copy link

I saw tediousjs/tedious#917 this issue. But why didn't you fix in the master branch?

Version:
"tedious": "^6.4.0",
"tedious-connection-pool": "^1.0.5",

Code:

function callProcedure(pool, name, params, ip='') {
return new Promise((resolve, reject) => {
pool.acquire(function (err, connection) {
var data = [];

        var request = new tedious.Request(name,  function (err, count, rows) {
            if (err) {
                //don't need to close the connection, put it back to pool
                connection.release();
                logger.error(`${ip}:${name}: ${err.stack}`)
                reject(`Error occured when executing request: ${err.stack}`)
                
            }
            else {
                //handle completion for current connection and request object
                //don't need to close the connection, put it back to pool
                connection.release();
            }
        });

        if (params != null && params.length > 0) {
            //add parameter to request, parameter should be initiated at each class
            for (var i = 0, len = params.length; i < len; i++) {
                request.addParameter(params[i].name, params[i].type, params[i].value)
            }
        }

        request.on('row', function (columns) {
            var obj = {};
            for (var i = 0, len = columns.length; i < len; i++) {
                obj[columns[i].metadata.colName] = columns[i].value;
            }
            data.push(obj);
        });
        
        request.on('doneProc', function (rowCount, more, returnStatus) {
            logger.info(`${ip}:${name}:Stored procedure ${name} executed, rows ${rowCount}, more ${more}, status ${returnStatus}`);
            resolve(JSON.stringify({data}))
        });

        if (connection != null) {
            connection.callProcedure(request);
        }
        else {
            logger.error(`${ip}:${name}: Custom error => Connection is null!`)
            reject('Custom error => Connection is null!')
        }
    });
});

}

Ianchocks said:
Hi @notestyle, are you having the same 'callback' issue as #917? If so are you also using tedious-connection-pool?

Edit: We actually don't have merge permissions for the tedious-connection-pool since it is a different repository than tedious itself.

@HuguesGauthier
Copy link

Hello ? can you fix this ?

@romullosantos
Copy link

Is there other option to tedious-connection-pool?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants