Skip to content

Support for non-transactional operations in asynclocalstorage transactions #14736

Closed
@GO-DIE

Description

@GO-DIE

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugWe've confirmed this is a bug in Mongoose and will fix it.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions