sequelize: RequestError: Timeout: Request failed to complete in 15000ms
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:
- Initiate sequelize with requestTimeout set to 30s
- Use a query that takes longer than 15s
- 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;
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 1
- Comments: 16 (2 by maintainers)
@nash90: I had the same issue. Try doing this instead:
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 },
A lot of different methods thrown around here, so I figured I’d put out what actually worked for me.
Putting
requestTimeout
inoptions
ordialectOptions
was not working for me.Thanks, This solution worked for mssql.
@cbogwill It seems not working for my case. BTW, I am using
mssql
dialect as well.Hello, anno 2021 I’ve got this working with the following code (I’m connecting to Azure, so I need encryption).
@cbogwill @nash90 Yes, that works. I missed the
options
level. Thank you, all!