Skip to content

Conversation

vkarpov15
Copy link
Collaborator

Summary

Good point by @hasezoey in #15430: if (Symbol.asyncIterator != null) checks are no longer necessary because Symbol.asyncIterator was introduced in node 10.x, and Mongoose 9 requires Node >= 18 currently (may change before we formally release Mongoose 9).

Examples

@vkarpov15 vkarpov15 added this to the 9.0 milestone May 26, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

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 removes legacy checks for Symbol.asyncIterator in Query and Aggregate prototypes, since Mongoose 9 requires Node.js ≥18 and async iteration support is guaranteed.

  • Drop conditional wrappers around async iterator definitions in both query.js and aggregate.js
  • Remove outdated comments about enabling async iteration in older Node versions

Reviewed Changes

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

File Description
lib/query.js Always define Query.prototype[Symbol.asyncIterator] and cleaned up legacy comments
lib/aggregate.js Always define Aggregate.prototype[Symbol.asyncIterator] and cleaned up legacy comments
Comments suppressed due to low confidence (3)

lib/query.js:5414

  • Consider updating the TypeScript type definitions to reflect that Query now always implements [Symbol.asyncIterator], ensuring consistency for TypeScript consumers.
Query.prototype[Symbol.asyncIterator] = function queryAsyncIterator() {

lib/aggregate.js:1148

  • Consider updating the TypeScript type definitions to reflect that Aggregate now always implements [Symbol.asyncIterator], ensuring consistency for TypeScript consumers.
Aggregate.prototype[Symbol.asyncIterator] = function() {

lib/query.js:5414

  • No new tests were added to verify the always-available async iterator behavior on Query and Aggregate. Consider adding unit tests to cover async iteration.
Query.prototype[Symbol.asyncIterator] = function queryAsyncIterator() {

Copy link
Collaborator

@AbdelrahmanHafez AbdelrahmanHafez left a comment

Choose a reason for hiding this comment

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

Nice!

@vkarpov15 vkarpov15 merged commit 6e40cb7 into 9.0 May 28, 2025
58 checks passed
@hasezoey hasezoey deleted the vkarpov15/remove-async-iterator-conditions branch May 29, 2025 08:06
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