diff --git a/packages/pg/lib/query.js b/packages/pg/lib/query.js index 824dee4e..514185eb 100644 --- a/packages/pg/lib/query.js +++ b/packages/pg/lib/query.js @@ -142,7 +142,7 @@ class Query extends EventEmitter { // the docs here: https://www.postgresql.org/docs/9.6/protocol-flow.html#PROTOCOL-FLOW-EXT-QUERY // say "Therefore, an Execute phase is always terminated by the appearance of exactly one of these messages: CommandComplete, EmptyQueryResponse (if the portal was created from an empty query string), ErrorResponse, or PortalSuspended." maybeSync(connection) { - if (this.isPreparedStatement) { + if (this.isPreparedStatement && !this._hasSentSync) { this._hasSentSync = true connection.sync() } diff --git a/packages/pg/test/integration/gh-issues/1105-tests.js b/packages/pg/test/integration/gh-issues/1105-tests.js index 2a36d699..d9885f8a 100644 --- a/packages/pg/test/integration/gh-issues/1105-tests.js +++ b/packages/pg/test/integration/gh-issues/1105-tests.js @@ -6,7 +6,7 @@ suite.testAsync('timeout causing query crashes', async () => { const client = new helper.Client() await client.connect() await client.query('CREATE TEMP TABLE foobar( name TEXT NOT NULL, id SERIAL)') - client.query('BEGIN') + await client.query('BEGIN') await client.query("SET LOCAL statement_timeout TO '1ms'") let count = 0 while (count++ < 5000) {