-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Updating from 5.10.4 to 5.10.5 is breaking a test using FakeTimers #9431
Comments
Are you actually using cursors, or are you just using We'll take a look this week and see if we can repro this issue. |
correct, in this particular case we are not using cursors, just using getOrderCountByProcDate() as written. thanks |
The below script seems to execute without any errors. Can you please modify the below script to demonstrate your issue? 'use strict';
const mongoose = require('mongoose');
mongoose.set('useFindAndModify', false);
const { Schema } = mongoose;
run().catch(err => console.log(err));
async function run() {
await mongoose.connect('mongodb://localhost:27017/test', {
useNewUrlParser: true,
useUnifiedTopology: true
});
await mongoose.connection.dropDatabase();
const Model = mongoose.model('Test', Schema({ name: String }));
await Model.create([
{ name: 'test1' },
{ name: 'test2' },
{ name: 'test3' }
]);
await Model.aggregate([{ $match: { name: { $exists: true } } }]).exec();
console.log('done');
} |
I think the following is closer to my scenario broken in 5.10.5:
|
@rvillane that script also executes correctly. Can you please create a script that demonstrates the error you're seeing? |
I believe my initial assessment of the issue is incorrect, after double checking the context of the failing function, is an integration test that uses FakeTimers "@sinonjs/fake-timers": "6.0.1" before executing, then is not related to Aggregate functions. FakeTimers.install({ now: new Date(2018, 11, 4) }); the integration test worked fine using mongoose 5.10.4 and is now broken with v5.10.5 This seems to be a duplicate of #9437 |
Do you want to request a feature or report a bug?
report a potential bug or looking for guidance about new functionality recently added
What is the current behavior?
After I updated mongoose from 5.10.4 to 5.10.5 , an Aggregation pipeline that runs a query is now broken. I know that in v5.10.5, AggregationCursor was improved with asyncIterator, however, in my particular case, I do not need to iterate the results, just return the matching records as a JSON response.
If the current behavior is a bug, please provide the steps to reproduce.
the following function executes an aggregation pipeline to find matching documents
and then, the function is called like this:
const results = await readModel.getOrderCountByProcDate(now.toDate());
with the AsyncIterator changes in version 5.10.5 is now throwing the following error:
What is the expected behavior?
The query is expected to run and return results. I tried adjusting the query according to the example provided in 5.10.5 code:
however when executing the for await loop, I'm getting the exact same socket hang up error indicated above.
Any ideas? if I run that Aggregation in a mongoDB client is works fine, then looks like the query itself is not the problem.
thanks
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
NodeJS v10.19.0
MongoDB Server 3.6.9
MongoDB native driver 3.6.2
Mongoose 5.10.5
The text was updated successfully, but these errors were encountered: