From a9fd34fb4217a7c16f02a4726efd61ad6a4f4796 Mon Sep 17 00:00:00 2001 From: Charmander <~@charmander.me> Date: Thu, 3 Apr 2025 15:10:49 -0700 Subject: [PATCH] Revert "docs: fix bug in transaction example (#3414)" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit dcb4257898d1d8d37110a4364922206dad33f9fe. The change doesn’t fix the bug it claims to (`finally` always runs) and introduces a resource leak if the `ROLLBACK` query fails. The related bug that a broken client can be returned to the pool remains unaffected either way. --- docs/pages/features/transactions.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/pages/features/transactions.mdx b/docs/pages/features/transactions.mdx index 4fc4a3cf..9280d1f4 100644 --- a/docs/pages/features/transactions.mdx +++ b/docs/pages/features/transactions.mdx @@ -31,10 +31,10 @@ try { const insertPhotoValues = [res.rows[0].id, 's3.bucket.foo'] await client.query(insertPhotoText, insertPhotoValues) await client.query('COMMIT') - client.release() } catch (e) { await client.query('ROLLBACK') - client.release() throw e +} finally { + client.release() } ```