github gajus/slonik v41.0.0

latest releases: v41.1.0, v41.0.1
14 days ago

New Slonik behavior means that you can no longer accidentally run a non-transaction query inside of a transaction.

If you receive an error UnexpectedForeignConnectionError, then you are trying to execute a query using a connection that is not associated with the transaction. This error is thrown to prevent accidental unsafe transaction handling, e.g.

connection.transaction(async (transactionConnection) => {
  await connection.query(sql.typeAlias('void')`INSERT INTO foo (bar) VALUES ('baz')`);
});

In this example, the query is executed using the connection that is not associated with the transaction. This is unsafe because the query is not part of the transaction and will not be rolled back if the transaction is aborted.

This behavior is achieved using AsyncLocalContext.

Don't miss a new slonik release

NewReleases is sending notifications on new releases.