Skip to content

fix(cursor): avoid waiting on buffering to run aggregation middleware - #16289

Merged
vkarpov15 merged 7 commits into
masterfrom
vkarpov15/gh-16284
May 28, 2026
Merged

fix(cursor): avoid waiting on buffering to run aggregation middleware#16289
vkarpov15 merged 7 commits into
masterfrom
vkarpov15/gh-16284

Conversation

@vkarpov15

Copy link
Copy Markdown
Collaborator

Summary

I was working on #16284, spotted a potential cause of flaking tests: aggregation cursor waits on buffering to run middleware, which is inconsistent with other places where we run middleware regardless of buffering. That is the likely cause for this test flake.

I also cranked up a timeout to see whether this failure was due to a buffering timeout or just slowness on the MongoDB server.

Examples

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR targets CI flakiness around aggregation cursors by changing when aggregation middleware runs relative to collection buffering, and by increasing a test suite timeout to help diagnose slow/buffering-related failures.

Changes:

  • Run pre('aggregate') middleware immediately when creating an AggregationCursor, instead of waiting for the collection buffer to drain.
  • Increase the Mocha timeout for aggregate.exec() tests to 15s.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
lib/cursor/aggregationCursor.js Adjusts aggregation cursor initialization to execute pre aggregate middleware without waiting on collection buffering.
test/aggregate.test.js Increases timeout for aggregate exec tests to reduce/diagnose CI flakes due to slowness/buffering.

Comment thread lib/cursor/aggregationCursor.js
Comment thread test/aggregate.test.js
Comment thread lib/cursor/aggregationCursor.js

@AbdelrahmanHafez AbdelrahmanHafez left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vkarpov15 vkarpov15 added this to the 9.7 milestone May 28, 2026
@vkarpov15
vkarpov15 merged commit 5337d91 into master May 28, 2026
71 of 72 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants