Repository navigation
Conversation
🦋 Changeset detectedLatest commit: c306b30 The changes in this PR will be included in the next version bump. This PR includes changesets to release 33 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
…nd narrow the changeset
This branch is waiting to be deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SqlResolvercan run a write that was issued outside a transaction on a concurrent transaction's connection, and the write is lost when that transaction rolls back even though the caller saw it succeed:The module documentation promises that batches are kept apart by the active transaction connection. All four resolver variants (
ordered,grouped,findById,void) share the same key function, so all are affected.transactionKeyfound the active transaction only through the genericSqlClientservice in the request's context. Callers of a layer-provided repository, or of a client built withmake, often do not carry that service, or carry a different client. The key was thenundefinedeven thoughmakeWithTransactionhad placed the client's own transaction service in the context, so both requests shared one batch that ran with the first entry's context. #9568 (for #9553) deliberately left SQL transaction grouping unchanged, so this case remained.makeWithTransactionnow also records its transaction service in an internalCurrentTransactionServicereference, next to the transaction level.transactionKeystill reads the genericSqlClient's transaction first, and reads the innermostmakeWithTransactiontransaction through that reference. When only one is active, it is the key, so the usual same-client case keeps the key it had before. When two different transactions are active, the key is the pair, which only splits batches further. Because the reference holds the service rather than the level, removing the transaction service from a context (afterCommitcallbacks, orContext.omit) also removes the fallback. The reference lives ininternal/, so there is no new public API.Known limitation: clients that implement
withTransactionthemselves instead of usingmakeWithTransaction, such as@effect/sql-sqlite-do, never set the reference. Their transactions are only recognized when that client is theSqlClientin the caller's context. This is documented onSqlResolver,SqlClient.withTransactionandmakeWithTransaction, and the sqlite-do fix is tracked separately.The regression tests in
packages/sql/sqlite-node/test/Resolver.test.tscover a caller whoseSqlClientis another client without a transaction, a caller inside another client's transaction, and a request that removed the transaction service from its context.Closes EFF-2929