Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for non-transactional operations in asynclocalstorage transactions #14736

Closed
2 tasks done
GO-DIE opened this issue Jul 10, 2024 · 0 comments · Fixed by #14744
Closed
2 tasks done

Support for non-transactional operations in asynclocalstorage transactions #14736

GO-DIE opened this issue Jul 10, 2024 · 0 comments · Fixed by #14744
Labels
confirmed-bug We've confirmed this is a bug in Mongoose and will fix it.
Milestone

Comments

@GO-DIE
Copy link

GO-DIE commented Jul 10, 2024

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the feature has not already been requested

🚀 Feature Proposal

mongoose.set('transactionAsyncLocalStorage', true);

const Test = mongoose.model('Test', mongoose.Schema({ name: String }));

const doc1 = new Test({ name: 'test1' });
const doc2 = new Test({ name: 'test2' });

// Save a new doc in a transaction that aborts
await connection.transaction(async() => {
await doc1.save();

await doc2.save(); // Do not want to use transactions in this operation
}).catch(() => {});

It cannot be done without using transactions in an “await doc2.save()” operation

Motivation

No response

Example

No response

@GO-DIE GO-DIE added enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature new feature This change adds new functionality, like a new method or class labels Jul 10, 2024
@vkarpov15 vkarpov15 added confirmed-bug We've confirmed this is a bug in Mongoose and will fix it. and removed new feature This change adds new functionality, like a new method or class enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature labels Jul 11, 2024
vkarpov15 added a commit that referenced this issue Jul 15, 2024
fix(model): support `session: null` option for `save()` to opt out of automatic `session` option with `transactionAsyncLocalStorage`
@vkarpov15 vkarpov15 added this to the 8.5.2 milestone Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug We've confirmed this is a bug in Mongoose and will fix it.
Projects
None yet
2 participants