Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/dialects/postgres/connection-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,10 @@ class ConnectionManager extends AbstractConnectionManager {
// This should help with backends incorrectly considering idle clients to be dead and prematurely disconnecting them.
// this feature has been added in pg module v6.0.0, check pg/CHANGELOG.md
'keepAlive',
// Times out queries after a set time in milliseconds. Added in pg v7.3
// Times out queries after a set time in milliseconds in the database end. Added in pg v7.3
'statement_timeout',
// Times out queries after a set time in milliseconds in client end, query would be still running in database end.
'query_timeout',
// Terminate any session with an open transaction that has been idle for longer than the specified duration in milliseconds. Added in pg v7.17.0 only supported in postgres >= 10
'idle_in_transaction_session_timeout'
]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ if (dialect.match(/^postgres/)) {
// `notice` is Postgres's default
expect(result[0].client_min_messages).to.equal('notice');
});

it('should time out the query request when the query runs beyond the configured query_timeout', async () => {
const sequelize = Support.createSequelizeInstance({
dialectOptions: { query_timeout: 100 }
});
const error = await sequelize.query('select pg_sleep(2)').catch(e => e);
expect(error.message).to.equal('Query read timeout');
});
});

describe('Dynamic OIDs', () => {
Expand Down