{"id":15560329,"url":"https://github.com/jdleesmiller/sequelize_statement_timeout","last_synced_at":"2026-04-19T14:30:58.358Z","repository":{"id":42358677,"uuid":"157903004","full_name":"jdleesmiller/sequelize_statement_timeout","owner":"jdleesmiller","description":"Demo for setting global and local postgresql statement_timeout with sequelizejs","archived":false,"fork":false,"pushed_at":"2022-08-30T22:24:43.000Z","size":29,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-29T04:17:14.404Z","etag":null,"topics":["nodejs","postgres","postgresql","sequelize","sequelizejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jdleesmiller.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-16T17:56:24.000Z","updated_at":"2020-07-17T08:30:21.000Z","dependencies_parsed_at":"2023-01-16T18:45:47.821Z","dependency_job_id":null,"html_url":"https://github.com/jdleesmiller/sequelize_statement_timeout","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jdleesmiller/sequelize_statement_timeout","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdleesmiller%2Fsequelize_statement_timeout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdleesmiller%2Fsequelize_statement_timeout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdleesmiller%2Fsequelize_statement_timeout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdleesmiller%2Fsequelize_statement_timeout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jdleesmiller","download_url":"https://codeload.github.com/jdleesmiller/sequelize_statement_timeout/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdleesmiller%2Fsequelize_statement_timeout/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32009796,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T20:23:30.271Z","status":"online","status_checked_at":"2026-04-19T02:00:07.110Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nodejs","postgres","postgresql","sequelize","sequelizejs"],"created_at":"2024-10-02T16:01:24.294Z","updated_at":"2026-04-19T14:30:58.340Z","avatar_url":"https://github.com/jdleesmiller.png","language":"JavaScript","readme":"# Sequelize `statment_timeout` Demo\n\nTest out how to set `statement_timeout` with [sequelize](http://docs.sequelizejs.com/).\n\nSetting a statement timeout can make your application more [robust against runaway queries](https://www.citusdata.com/blog/2017/04/28/postgres-tips-for-rails/). This demo shows how to set a global statement timeout and also provide a longer timeout for a specific transaction using `SET LOCAL statement_timeout`.\n\n## Setup\n\n```\ndocker-compose build\ndocker-compose up\n```\n\n## Output\n\nThe code in [index.js](index.js) produces the following output:\n\n```\ntest_1  | Fast query without transaction:\ntest_1  | Executing (default): SELECT 1\ntest_1  | [ [ { '?column?': 1 } ],\ntest_1  |   Result {\ntest_1  |     command: 'SELECT',\ntest_1  |     rowCount: 1,\ntest_1  |     oid: null,\ntest_1  |     rows: [ [Object] ],\ntest_1  |     fields: [ [Field] ],\ntest_1  |     _parsers: [ [Function] ],\ntest_1  |     RowCtor: null,\ntest_1  |     rowAsArray: false,\ntest_1  |     _getTypeParser: [Function: bound ] } ]\ntest_1  |\ntest_1  | Slow query without transaction:\ntest_1  | Executing (default): SELECT pg_sleep(2)\ndb_1    | 2018-11-16 17:54:38.917 UTC [131] ERROR:  canceling statement due to statement timeout\ndb_1    | 2018-11-16 17:54:38.917 UTC [131] STATEMENT:  SELECT pg_sleep(2)\ntest_1  | canceling statement due to statement timeout\ntest_1  |\ntest_1  | Slow query in transaction without local statement timeout:\ntest_1  | Executing (2d4a8cb9-d5a3-41db-b815-8fd294c57827): START TRANSACTION;\ntest_1  | Executing (2d4a8cb9-d5a3-41db-b815-8fd294c57827): SELECT pg_sleep(2)\ntest_1  | canceling statement due to statement timeout\ntest_1  | Executing (2d4a8cb9-d5a3-41db-b815-8fd294c57827): COMMIT;\ndb_1    | 2018-11-16 17:54:39.939 UTC [131] ERROR:  canceling statement due to statement timeout\ndb_1    | 2018-11-16 17:54:39.939 UTC [131] STATEMENT:  SELECT pg_sleep(2)\ntest_1  |\ntest_1  | Slow query in transaction with local statement timeout:\ntest_1  | Executing (fe7615b6-19cd-44ed-8e63-7694c499097a): START TRANSACTION;\ntest_1  | Executing (fe7615b6-19cd-44ed-8e63-7694c499097a): SET LOCAL statement_timeout = 3000\ntest_1  | Executing (fe7615b6-19cd-44ed-8e63-7694c499097a): SELECT pg_sleep(2)\ntest_1  | [ [ { pg_sleep: '' } ],\ntest_1  |   Result {\ntest_1  |     command: 'SELECT',\ntest_1  |     rowCount: 1,\ntest_1  |     oid: null,\ntest_1  |     rows: [ [Object] ],\ntest_1  |     fields: [ [Field] ],\ntest_1  |     _parsers: [ [Function: noParse] ],\ntest_1  |     RowCtor: null,\ntest_1  |     rowAsArray: false,\ntest_1  |     _getTypeParser: [Function: bound ] } ]\ntest_1  | Executing (fe7615b6-19cd-44ed-8e63-7694c499097a): COMMIT;\n```\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdleesmiller%2Fsequelize_statement_timeout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdleesmiller%2Fsequelize_statement_timeout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdleesmiller%2Fsequelize_statement_timeout/lists"}