Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix tests
  • Loading branch information
vkarpov15 committed May 13, 2024
commit 3c74f46c19839496a7c89a5ae1d68a06db6f9d78
2 changes: 1 addition & 1 deletion lib/aggregate.js
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,7 @@ Aggregate.prototype.exec = async function exec() {
applyGlobalMaxTimeMS(this.options, model.db.options, model.base.options);
applyGlobalDiskUse(this.options, model.db.options, model.base.options);

const asyncLocalStorage = this.model?.db?.base.transactionAsyncLocalStorage?.getStore();
const asyncLocalStorage = this.model()?.db?.base.transactionAsyncLocalStorage?.getStore();
if (!this.options.hasOwnProperty('session') && asyncLocalStorage?.session != null) {
this.options.session = asyncLocalStorage.session;
}
Expand Down
8 changes: 4 additions & 4 deletions test/docs/transactions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ describe('transactions', function() {
await Test.createCollection();
await Test.deleteMany({});

const doc = new Test({ name: 'test' });
const doc = new Test({ name: 'test_transactionAsyncLocalStorage' });
await assert.rejects(
() => m.connection.transaction(async() => {
await doc.save();
Expand All @@ -383,10 +383,10 @@ describe('transactions', function() {
docs = await Test.find({ _id: doc._id });
assert.equal(docs.length, 1);

docs = await Promise.all([async() => {
docs = await async function test() {
return await Test.findOne({ _id: doc._id });
}]).then(res => res[0]);
assert.equal(docs.length, 1);
}();
assert.equal(doc.name, 'test_transactionAsyncLocalStorage');

throw new Error('Oops!');
}),
Expand Down