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

RequestError: Timeout: Request failed to complete in 15000ms #11035

Open
nash90 opened this issue Jun 5, 2019 · 16 comments
Open

RequestError: Timeout: Request failed to complete in 15000ms #11035

nash90 opened this issue Jun 5, 2019 · 16 comments
Labels
existing workaround For issues. There is a known workaround for this issue. status: understood For issues. Applied when the issue is understood / reproducible. type: other For issues and PRs. Something that does not fit in any of the other "type:" labels.

Comments

@nash90
Copy link

nash90 commented Jun 5, 2019

Issue: unable to set requestTimeout with configuration parameter for "mssql" dilect
No matter whatever value is in requestTimeout parameter, the driver sets default value of "15000ms".
Hence, Timeout error occurs for all query that takes longer than 15s.

Application log is as follows:

Executing (default): SELECT [AnalysisTagID], [RefDate], [CategorySet], [AssetID], [Category] FROM [EMA_RiskAllocCategoriesView] AS [EMA_RiskAllocCategoriesView] ORDER BY [EMA_RiskAllocCategoriesView].[AssetID] OFFSET 0 ROWS FETCH NEXT 3 ROWS ONLY;
Error EMA_RiskAllocCategoriesView.getAll DatabaseError [SequelizeDatabaseError]: Timeout: Request failed to complete in 15000ms
    at Query.formatError (/Users/abinash/Desktop/my-app/new-dashboard/ember-electron/resources/sapiat-server/node_modules/sequelize/lib/dialects/mssql/query.js:309:12)
    at Request.userCallback (/Users/abinash/Desktop/my-app/new-dashboard/ember-electron/resources/sapiat-server/node_modules/sequelize/lib/dialects/mssql/query.js:69:23)
    at Request.callback (/Users/abinash/Desktop/my-app/new-dashboard/ember-electron/resources/sapiat-server/node_modules/tedious/lib/request.js:37:27)
    at Connection.message (/Users/abinash/Desktop/my-app/new-dashboard/ember-electron/resources/sapiat-server/node_modules/tedious/lib/connection.js:2181:24)
    at Connection.dispatchEvent (/Users/abinash/Desktop/my-app/new-dashboard/ember-electron/resources/sapiat-server/node_modules/tedious/lib/connection.js:1172:36)
    at MessageIO.<anonymous> (/Users/abinash/Desktop/my-app/new-dashboard/ember-electron/resources/sapiat-server/node_modules/tedious/lib/connection.js:1045:14)
    at MessageIO.emit (events.js:200:13)
    at Message.<anonymous> (/Users/abinash/Desktop/my-app/new-dashboard/ember-electron/resources/sapiat-server/node_modules/tedious/lib/message-io.js:32:14)
    at Message.emit (events.js:205:15)
    at endReadableNT (/Users/abinash/Desktop/my-app/new-dashboard/ember-electron/resources/sapiat-server/node_modules/tedious/node_modules/readable-stream/lib/_stream_readable.js:1077:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:9) {
  name: 'SequelizeDatabaseError',
  parent: RequestError: Timeout: Request failed to complete in 15000ms
      at RequestError (/Users/abinash/Desktop/my-app/new-dashboard/ember-electron/resources/sapiat-server/node_modules/tedious/lib/errors.js:32:12)
      at Connection.requestTimeout (/Users/abinash/Desktop/my-app/new-dashboard/ember-electron/resources/sapiat-server/node_modules/tedious/lib/connection.js:1117:21)
      at Timeout._onTimeout (/Users/abinash/Desktop/my-app/new-dashboard/ember-electron/resources/sapiat-server/node_modules/tedious/lib/connection.js:1085:14)
      at listOnTimeout (internal/timers.js:531:17)
      at processTimers (internal/timers.js:475:7) {
    message: 'Timeout: Request failed to complete in 15000ms',
    code: 'ETIMEOUT',
    sql: 'SELECT [AnalysisTagID], [RefDate], [CategorySet], ' +
      '[AssetID], [Category] FROM [EMA_RiskAllocCategoriesView] ' +
      'AS [EMA_RiskAllocCategoriesView] ORDER BY ' +
      '[EMA_RiskAllocCategoriesView].[AssetID] OFFSET 0 ROWS ' +
      'FETCH NEXT 3 ROWS ONLY;'
  },

What are you doing?

sequelize is instantiated as follows where requestTimeout is set to 30s

const sequelize = new Sequelize(config.db.schema, config.db.username, config.db.password, {  
  "host": config.db.url,
  "dialect": "mssql",
  "dialectOptions": {
    "requestTimeout": 300000
  },
  pool: {
    max: 5,
    min: 0,
    acquire: 30000,
    idle: 10000
  }
});

A query that does full scan in a large table is run as follows:

EMA_RiskAllocCategoriesView.findAll({
    }).catch((err)=>{
      console.log("Error EMA_RiskAllocCategoriesView.getAll",err)
    });

To Reproduce
Steps to reproduce the behavior:

  1. Initiate sequelize with requestTimeout set to 30s
  2. Use a query that takes longer than 15s
  3. See error which says "Request failed to complete in 15000ms"

What do you expect to happen?

Not thow request timeout error for queries that run for 30s if sequelize is set to have requestTimeout of 30s.

What is actually happening?

Timeout Error for all query that takes longer than 15 s

Output, either JSON or SQL

Executing (default): SELECT [AnalysisTagID], [RefDate], [CategorySet], [AssetID], [Category] FROM [EMA_RiskAllocCategoriesView] AS [EMA_RiskAllocCategoriesView] ORDER BY [EMA_RiskAllocCategoriesView].[AssetID] OFFSET 0 ROWS FETCH NEXT 3 ROWS ONLY;
Error EMA_RiskAllocCategoriesView.getAll DatabaseError [SequelizeDatabaseError]: Timeout: Request failed to complete in 15000ms
    at Query.formatError (/Users/abinash/Desktop/my-app/new-dashboard/ember-electron/resources/sapiat-server/node_modules/sequelize/lib/dialects/mssql/query.js:309:12)
    at Request.userCallback (/Users/abinash/Desktop/my-app/new-dashboard/ember-electron/resources/sapiat-server/node_modules/sequelize/lib/dialects/mssql/query.js:69:23)
    at Request.callback (/Users/abinash/Desktop/my-app/new-dashboard/ember-electron/resources/sapiat-server/node_modules/tedious/lib/request.js:37:27)
    at Connection.message (/Users/abinash/Desktop/my-app/new-dashboard/ember-electron/resources/sapiat-server/node_modules/tedious/lib/connection.js:2181:24)
    at Connection.dispatchEvent (/Users/abinash/Desktop/my-app/new-dashboard/ember-electron/resources/sapiat-server/node_modules/tedious/lib/connection.js:1172:36)
    at MessageIO.<anonymous> (/Users/abinash/Desktop/my-app/new-dashboard/ember-electron/resources/sapiat-server/node_modules/tedious/lib/connection.js:1045:14)
    at MessageIO.emit (events.js:200:13)
    at Message.<anonymous> (/Users/abinash/Desktop/my-app/new-dashboard/ember-electron/resources/sapiat-server/node_modules/tedious/lib/message-io.js:32:14)
    at Message.emit (events.js:205:15)
    at endReadableNT (/Users/abinash/Desktop/my-app/new-dashboard/ember-electron/resources/sapiat-server/node_modules/tedious/node_modules/readable-stream/lib/_stream_readable.js:1077:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:9) {
  name: 'SequelizeDatabaseError',
  parent: RequestError: Timeout: Request failed to complete in 15000ms
      at RequestError (/Users/abinash/Desktop/my-app/new-dashboard/ember-electron/resources/sapiat-server/node_modules/tedious/lib/errors.js:32:12)
      at Connection.requestTimeout (/Users/abinash/Desktop/my-app/new-dashboard/ember-electron/resources/sapiat-server/node_modules/tedious/lib/connection.js:1117:21)
      at Timeout._onTimeout (/Users/abinash/Desktop/my-app/new-dashboard/ember-electron/resources/sapiat-server/node_modules/tedious/lib/connection.js:1085:14)
      at listOnTimeout (internal/timers.js:531:17)
      at processTimers (internal/timers.js:475:7) {
    message: 'Timeout: Request failed to complete in 15000ms',
    code: 'ETIMEOUT',
    sql: 'SELECT [AnalysisTagID], [RefDate], [CategorySet], ' +
      '[AssetID], [Category] FROM [EMA_RiskAllocCategoriesView] ' +
      'AS [EMA_RiskAllocCategoriesView] ORDER BY ' +
      '[EMA_RiskAllocCategoriesView].[AssetID] OFFSET 0 ROWS ' +
      'FETCH NEXT 3 ROWS ONLY;'
  },

Environment

Dialect:

  • mssql

Dialect library version: tedious 6.1.2
Database version: mcr.microsoft.com/mssql/server:2017-latest (docker)
Sequelize version: 5.8.7
Node Version: v12.3.1
OS: osx
If TypeScript related: TypeScript version: XXX
Tested with latest release:

  • No

Self investigation.
hard coded fix is to change the value of the following variable in "lib/connection.js" module of tedious library
const DEFAULT_CLIENT_REQUEST_TIMEOUT = 15 * 1000;

@cbogwill
Copy link

cbogwill commented Jul 2, 2019

@nash90:
I had the same issue. Try doing this instead:

"dialectOptions": {
    options: { "requestTimeout": 300000 }
  },

@papb
Copy link
Member

papb commented Jul 25, 2019

@nash90 Does the above workaround work for you?

@papb papb added status: awaiting response For issues and PRs. OP must respond (or change something, if it is a PR). Maintainers have no action type: other For issues and PRs. Something that does not fit in any of the other "type:" labels. labels Jul 25, 2019
@Yaowenjie
Copy link

Yaowenjie commented Aug 1, 2019

@cbogwill
It seems not working for my case. BTW, I am using mssql dialect as well.

@nash90
Copy link
Author

nash90 commented Aug 1, 2019

@papb @Yaowenjie
The solution provided by @cbogwill worked.

@nash90
Copy link
Author

nash90 commented Aug 1, 2019

@nash90:
I had the same issue. Try doing this instead:

"dialectOptions": {
    options: { "requestTimeout": 300000 }
  },

Thanks, This solution worked for mssql.

@Yaowenjie
Copy link

Yaowenjie commented Aug 1, 2019

@cbogwill @nash90
Yes, that works. I missed the options level. Thank you, all!

@nash90
Copy link
Author

nash90 commented Aug 1, 2019

@cbogwill @nash90
Yes, that works. I missed the options level. Thank you, all!

By the way, that setting was in sequelize source code "lib/dialects/mssql/connection-manager.js"
https://github.com/sequelize/sequelize/pull/11045/files#diff-3aa0e1a84e1c794951afaa682fde719dR60

@papb papb added the existing workaround For issues. There is a known workaround for this issue. label Aug 1, 2019
@papb papb self-assigned this Aug 1, 2019
@papb papb added status: understood For issues. Applied when the issue is understood / reproducible. and removed status: awaiting response For issues and PRs. OP must respond (or change something, if it is a PR). Maintainers have no action labels Aug 1, 2019
@ongkristopher
Copy link

@nash90:
I had the same issue. Try doing this instead:

"dialectOptions": {
    options: { "requestTimeout": 300000 }
  },

Ignoring invalid configuration option passed to Connection: options. This is currently a warning, but in future versions of MySQL2, an error will be thrown if you pass an invalid configuration options to a Connection

this is showing on my log using that format.

@jeserg
Copy link

jeserg commented Feb 7, 2020

I am using the mssql driver and my configuration -
const config = {
user: 'login',
password: 'pass',
server: '10.11.24.15',
port: 1433,
database: 'base',
options: {
'enableArithAbort': true,
'requestTimeout': 130000,
'idleTimeoutMillis': 130000
},

pool: {
max: 10,
min: 0,
idleTimeoutMillis: 130000
}
}

@ashokkumarg
Copy link

ashokkumarg commented May 21, 2020

I tried using both of the dialectOptions to the configuration as below but still I face the same issue

dialectOptions: {
"requestTimeout": 300000
}

dialectOptions: {
options: { "requestTimeout": 300000 }
}

const DBConfig = {
  user: 'username',
  password: '*******',
  host: 'host name',
  port: 1455,
  database: 'database name',
  server: 'server name',
  dialect: "mssql"
};

**RequestError: Timeout: Request failed to complete in 15000ms**

@854770857
Copy link

@ashokkumarg
How was it resolved in the end?

@jepalen
Copy link

jepalen commented Dec 28, 2020

For me in NodeJs with Mssql worked just this small change:
just put outside of the options the field requestTimeout

const config = {
user: 'login',
password: 'pass',
server: '10.11.24.15',
port: 1433,
database: 'base',
'requestTimeout': 130000,
options: {
'enableArithAbort': true,
'idleTimeoutMillis': 130000
},

@davidbouckaert
Copy link

davidbouckaert commented Jun 2, 2021

Hello, anno 2021 I've got this working with the following code (I'm connecting to Azure, so I need encryption).

  client: 'mssql',
  connection: {
    host: '*****',
    user: '*****',
    password: '*****',
    options: { requestTimeout: 300000, encrypt: true },
  },
});

@tensajougan8
Copy link

You need to hard code it
add this to the config

dialectOptions:{
requestTimeout: 300000
}

add the following to
\sequelize\lib\dialects\mssql\connection-manager-> connectionConfig

requestTimeout: config.dialectOptions.requestTimeout

by @nash90

@github-actions
Copy link
Contributor

github-actions bot commented Nov 9, 2021

This issue has been automatically marked as stale because it has been open for 14 days without activity. It will be closed if no further activity occurs within the next 14 days. If this is still an issue, just leave a comment or remove the "stale" label. 🙂

@github-actions github-actions bot added the stale label Nov 9, 2021
@WikiRik WikiRik removed the stale label Nov 15, 2021
@SpringsTea
Copy link

A lot of different methods thrown around here, so I figured I'd put out what actually worked for me.

const connection = require('knex')({
  client: 'mssql',
  connection: {
    host :  'hostaddress',
    user : user,
    password : password,
    requestTimeout: 600000,// this part worked for me, 10 min timeout
    database : 'DBName'
  }
});

Putting requestTimeout in options or dialectOptions was not working for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
existing workaround For issues. There is a known workaround for this issue. status: understood For issues. Applied when the issue is understood / reproducible. type: other For issues and PRs. Something that does not fit in any of the other "type:" labels.
Projects
None yet
Development

No branches or pull requests