question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

msnodesqlv8 bug: Connection is busy with results for another command

See original GitHub issue

I have found an issue when executing a stored procedure which raises an error concurrently using the msnodesqlv8 driver. Actually, it happens if the procedure does not exist as well.

I am not sure if it is a bug in mssql or in msnodesqlv8 itself. I report it here as my code is not using msnodesqlv8 directly. The problem is with the versions

mssql: 3.3.0 msnodesqlv8: 0.2.x (I have tried with the latest and many other releases)

However, it works with msnodesqlv8 0.1.46. So it seems that it was introduced in the 0.2.x releases.

I have narrowed the problem to the following minimal code:

'use strict';

const sql = require('mssql');

sql.connect({
  driver: 'msnodesqlv8',
  server: 'localhost',
  database: 'master',
  options: { trustedConnection: true }
}).then(db=>{
  let array = [];

  for (let i=0; i<100; i++){
    array.push(i);
  }

  return Promise.all(array.map(i=>{
    let request = db.request();
    // test should raise an error, or just don't exist at all
    return request.execute('test').catch(err=>{
      console.log(err);
    });
  }));

}).then(()=>{
  process.exit(0);
}).catch(err=>{
  console.log(err);
  process.exit(-1);
});

When it works, you expect the errors to be like

{ [RequestError: error]
  name: 'RequestError',
  message: 'error',
  code: 'EREQUEST',
  number: 50000,
  lineNumber: undefined,
  state: '42000',
  class: undefined,
  serverName: undefined,
  procName: undefined }

(or whatever error the procedure throws)

However, with the latest version, I get many instances of the following error:

{ [RequestError: Connection is busy with results for another command]
  name: 'RequestError',
  message: 'Connection is busy with results for another command',
  code: 'EREQUEST',
  number: 0,
  lineNumber: undefined,
  state: 'HY000',
  class: undefined,
  serverName: undefined,
  procName: undefined }

I do not know if this this could affect to concurrent operations to the faulty one that do not raise any errors.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
TimelordUKcommented, Dec 21, 2018

That is interesting. I will take a look at this issue to see why 16 does not terminate a statement correctly.

I’ll report back when I know more. Can I reproduce this issue with a raise error 16 statement ?

Sent from my iPhone

On 20 Dec 2018, at 16:31, Kyle Hoskins notifications@github.com wrote:

@TimelordUK Thanks for your work on msnodesqlv8. I have an old setup where updating to 0.2.16 avoids connection is busy when severity is 14 (ex: constraint issue) as described; however, it there something I can override so that severity 16 issues don’t cause it as well? Any attempted addition over the specified column length (severity 16) causes connection is busy for us. We’re using the loopback framework with msnodesqlv8 as the driver.

Thanks, Kyle

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

1reaction
kyle-apexcommented, Dec 20, 2018

@TimelordUK Thanks for your work on msnodesqlv8. I have an old setup where updating to 0.2.16 avoids connection is busy when severity is 14 (ex: constraint issue) as described; however, it there something I can override so that severity 16 issues don’t cause it as well? Any attempted addition over the specified column length (severity 16) causes connection is busy for us. We’re using the loopback framework with msnodesqlv8 as the driver.

Thanks, Kyle

Read more comments on GitHub >

github_iconTop Results From Across the Web

msnodesqlv8 bug: Connection is busy with results for another ...
I have found an issue when executing a stored procedure which raises an error concurrently using the msnodesqlv8 driver.
Read more >
[SQL Server Native Client 11.0]Connection is busy with results ...
This error typically happens when you issue a query using a Command and then start reading the results using a DataReader. And then,...
Read more >
Why only some users get the error: "Connection is busy with ...
The "Connection is busy with results for another command" error means that there are at least two queries that use the same connection....
Read more >
msnodesqlv8 - npm
Node JS support for SQL server (and other databases with ODBC compliant ... items such that all connections are busy providing work exists....
Read more >
node-mssql | Microsoft SQL Server client for Node.js
Providing a different connection config to the connect() function will not ... require('mssql/msnodesqlv8') ) or a connection.on is not a function error ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found