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

3.3.0: requestTimeout in config is not passed to connection's config #392

Closed
jcollum opened this issue Dec 12, 2016 · 6 comments
Closed

Comments

@jcollum
Copy link

jcollum commented Dec 12, 2016

$ cat node_modules/mssql/package.json | grep version
  "version": "3.3.0"

$ node --version
v6.9.1

Code:

 sql: function(library, dbConfig) {
      logger.debug("Connecting to SQL");
      return new Promise(function(resolve, reject) {
        var conn;
        conn = new library.Connection(dbConfig);
        logger.trace("Connection config:", dbConfig);
        return conn.connect(function(err) {
          if (err != null) {
            logger.error("SQL connection failed", dbConfig, err);
            return reject(new Error(err));
          } else {
            logger.debug("Connected.");
            logger.trace("Connection details:", conn);
            return resolve(conn);
          }
        });
      });
    },

However when I stop on line that has logger.debug("Connected."); (3rd to last LOC from the bottom) I see this:

debugger output

Also the conn config options (forgot those in the screenshot):

conn.config.options.requestTimeout
15000

It works fine, most of the time. But I have some fairly long running requests in this app, 5 minutes or more. Many of them are failing because the requestTimeout is too low.

I believe I am following the docs though and passing in the requestTimeout in the appropriate place.

(I've added an event listener for the 'error' event after spotting that section of the docs ;) )

@jcollum
Copy link
Author

jcollum commented Dec 12, 2016

I see the issue now: connectionTimeout and requestTimeout have to be passed in in a subobject called options. WOW the docs are very unclear about that:

https://github.com/patriksimek/node-mssql/blame/master/README.md#L395

I don't see any mention of options around there!

@GregorioLopez
Copy link

I had the same problem. I too think the subobject options is not well documented.

I didn't know how to execute heavy querys. Thanks to jcollum.

@patriksimek
Copy link
Collaborator

This is strange, the requestTimeout should work without specifying it inside options. As you can see here It is copied to options automatically. Thats why I didn't mention this in the docs.

@0xAlwaysDumpling
Copy link

i am running into this same issue, when i try to set requesttimeout > 15 seconds it will time out at the default. Anything less than 15 will work. using 3.3.0

@rainabba
Copy link

rainabba commented Mar 5, 2017

I've tried both of the following and none address the 'Timeout: Request failed to complete in 15000ms', error.

When I break and inspect my request.connection.config.options.requestTimeout and connectTimeout objects, both still show 15000. If I add request.connection.config.options.requestTimeout=700000 just before my execute call, it doesn't timeout though so it also appears to me that the requestTimeout is not being passed through. I'm also on 3.3.0

Also, -1 and Infinity don't work as expected even when I set the requestTimeout that way as I'd expect based on #157

{
    user: '******',
    password: '******',
    server: '*******',
    database: '*******',
    logDebug: false,
    option: {
        requestTimeout: -1
    }
}
{
    user: '******',
    password: '******',
    server: '*******',
    database: '*******',
    logDebug: false,
    requestTimeout: -1
}
{
    user: '******',
    password: '******',
    server: '*******',
    database: '*******',
    logDebug: false,
    option: {
        requestTimeout: 700000
    }
}
{
    user: '******',
    password: '******',
    server: '*******',
    database: '*******',
    logDebug: false,
    requestTimeout: 700000
}

@dhensby
Copy link
Collaborator

dhensby commented Mar 8, 2019

v3.3.0 is very old and out of support. We haven't had reports of this in v4 and we are now running v5 (with v6 in alpha) so I'm closing this as outdated

@dhensby dhensby closed this as completed Mar 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants