{"action":"created","issue":{"url":"https://api.github.com/repos/brianc/node-postgres/issues/1454","repository_url":"https://api.github.com/repos/brianc/node-postgres","labels_url":"https://api.github.com/repos/brianc/node-postgres/issues/1454/labels{/name}","comments_url":"https://api.github.com/repos/brianc/node-postgres/issues/1454/comments","events_url":"https://api.github.com/repos/brianc/node-postgres/issues/1454/events","html_url":"https://github.com/brianc/node-postgres/issues/1454","id":257874584,"number":1454,"title":"Fails to error on queries inside a transaction after a lost connection","user":{"login":"vitaly-t","id":5108906,"avatar_url":"https://avatars1.githubusercontent.com/u/5108906?v=4","gravatar_id":"","url":"https://api.github.com/users/vitaly-t","html_url":"https://github.com/vitaly-t","followers_url":"https://api.github.com/users/vitaly-t/followers","following_url":"https://api.github.com/users/vitaly-t/following{/other_user}","gists_url":"https://api.github.com/users/vitaly-t/gists{/gist_id}","starred_url":"https://api.github.com/users/vitaly-t/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vitaly-t/subscriptions","organizations_url":"https://api.github.com/users/vitaly-t/orgs","repos_url":"https://api.github.com/users/vitaly-t/repos","events_url":"https://api.github.com/users/vitaly-t/events{/privacy}","received_events_url":"https://api.github.com/users/vitaly-t/received_events","type":"User","site_admin":false},"labels":[{"id":112059,"url":"https://api.github.com/repos/brianc/node-postgres/labels/bug","name":"bug","color":"e10c02","default":true}],"state":"open","locked":false,"assignee":{"login":"brianc","id":50081,"avatar_url":"https://avatars0.githubusercontent.com/u/50081?v=4","gravatar_id":"","url":"https://api.github.com/users/brianc","html_url":"https://github.com/brianc","followers_url":"https://api.github.com/users/brianc/followers","following_url":"https://api.github.com/users/brianc/following{/other_user}","gists_url":"https://api.github.com/users/brianc/gists{/gist_id}","starred_url":"https://api.github.com/users/brianc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brianc/subscriptions","organizations_url":"https://api.github.com/users/brianc/orgs","repos_url":"https://api.github.com/users/brianc/repos","events_url":"https://api.github.com/users/brianc/events{/privacy}","received_events_url":"https://api.github.com/users/brianc/received_events","type":"User","site_admin":false},"assignees":[{"login":"brianc","id":50081,"avatar_url":"https://avatars0.githubusercontent.com/u/50081?v=4","gravatar_id":"","url":"https://api.github.com/users/brianc","html_url":"https://github.com/brianc","followers_url":"https://api.github.com/users/brianc/followers","following_url":"https://api.github.com/users/brianc/following{/other_user}","gists_url":"https://api.github.com/users/brianc/gists{/gist_id}","starred_url":"https://api.github.com/users/brianc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brianc/subscriptions","organizations_url":"https://api.github.com/users/brianc/orgs","repos_url":"https://api.github.com/users/brianc/repos","events_url":"https://api.github.com/users/brianc/events{/privacy}","received_events_url":"https://api.github.com/users/brianc/received_events","type":"User","site_admin":false}],"milestone":null,"comments":5,"created_at":"2017-09-14T22:26:20Z","updated_at":"2017-09-17T23:23:13Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"When we execute a lengthy operation inside a transaction, and the connection is suddenly lost during that time, then any query we execute on the `client` after that become stuck, i.e. they report nether success no error:\r\n\r\n```js\r\n'use strict';\r\n\r\nconst Pool = require('pg-pool');\r\n\r\nconst cn = {\r\n    database: 'newone',\r\n    port: 5433,\r\n    user: 'postgres'\r\n};\r\n\r\nconst p = new Pool(cn);\r\n\r\np.on('error', error => {\r\n    // do nothing\r\n});\r\n\r\np.connect((err, client, release) => {\r\n    if (err) {\r\n        console.log('Failed to connect:', err);\r\n        return;\r\n    }\r\n    const test = async function () {\r\n        try {\r\n            await client.query('BEGIN');\r\n            await client.query('SELECT pg_sleep(10)'); // connection breaks during this one\r\n            await client.query('COMMIT');\r\n            console.log('success!');\r\n        } catch (e) {\r\n            console.log('about to rollback...'); // this is reported\r\n            await client.query('ROLLBACK'); // this one is stuck, never reporting an error, if the error was due to lost connection\r\n            console.log('rollback finished'); // this is never reported, if we are here because of lost connection\r\n        } finally {\r\n            release();\r\n            p.end();\r\n        }\r\n    };\r\n\r\n    test();\r\n});\r\n```\r\n\r\nI've tried both `pg-pool` directly and via `node-postgres`, versions 6.x and 7.x - all the same.\r\n\r\n**Expected Behavior**\r\n\r\nExecuting any query against `client` at that point should immediately report an error that informs us of the lost connectivity.\r\n"},"comment":{"url":"https://api.github.com/repos/brianc/node-postgres/issues/comments/330101295","html_url":"https://github.com/brianc/node-postgres/issues/1454#issuecomment-330101295","issue_url":"https://api.github.com/repos/brianc/node-postgres/issues/1454","id":330101295,"user":{"login":"vitaly-t","id":5108906,"avatar_url":"https://avatars1.githubusercontent.com/u/5108906?v=4","gravatar_id":"","url":"https://api.github.com/users/vitaly-t","html_url":"https://github.com/vitaly-t","followers_url":"https://api.github.com/users/vitaly-t/followers","following_url":"https://api.github.com/users/vitaly-t/following{/other_user}","gists_url":"https://api.github.com/users/vitaly-t/gists{/gist_id}","starred_url":"https://api.github.com/users/vitaly-t/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vitaly-t/subscriptions","organizations_url":"https://api.github.com/users/vitaly-t/orgs","repos_url":"https://api.github.com/users/vitaly-t/repos","events_url":"https://api.github.com/users/vitaly-t/events{/privacy}","received_events_url":"https://api.github.com/users/vitaly-t/received_events","type":"User","site_admin":false},"created_at":"2017-09-17T23:23:13Z","updated_at":"2017-09-17T23:23:13Z","author_association":"CONTRIBUTOR","body":"@brianc any luck? Do you need help with it? 😉 "}}
{"actor":{"display_login":"vitaly-t"}}