Skip to content

fix: await post.populate() in test to prevent dangling promise on Node 18 - #16366

Merged
vkarpov15 merged 2 commits into
masterfrom
copilot/fix-github-actions-job-node-18-mongodb-7-0-7
Jul 20, 2026
Merged

fix: await post.populate() in test to prevent dangling promise on Node 18#16366
vkarpov15 merged 2 commits into
masterfrom
copilot/fix-github-actions-job-node-18-mongodb-7-0-7

Conversation

Copilot AI commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

The CI job "Node 18 MongoDB 7.0.7 OS ubuntu-22.04" on the 7.x branch fails with a 2000ms timeout in the beforeEach hook for the "using multiple populate calls" test. Two bugs in 7.x's test/util.js are the primary root causes (both already fixed on master via f40ce4555):

  1. clearTestData — missing return after the first successful dropDatabase() causes the DB to be dropped up to 5× per test. By the 4th test, 15+ sequential drops cause MongoDB 7.0.7 to respond slowly enough that the next User.create() exceeds the Mocha timeout.
  2. stopRemainingOps — sets buffer=true on collections but doesn't remove them from db.collections cache, so freshly registered models in the next beforeEach may inherit a buffered collection.

To fully fix the 7.x CI, the test/util.js changes from master need to be backported to 7.x.

Changes

  • test/document.populate.test.js: Add await to the previously fire-and-forget post.populate(param) call in "using multiple populate calls". Without await, a dangling Promise is left in-flight when clearTestData drops the DB, which can produce an unhandled rejection and leaves a permanently buffered operation stuck in the collection queue.
// Before — unawaited, leaves a pending populate when DB is dropped
post.populate(param);

// After — awaited, cleans up before test teardown
await post.populate(param);

Copilot AI changed the title [WIP] Fix failing GitHub Actions job Node 18 MongoDB 7.0.7 fix: await post.populate() in test to prevent dangling promise on Node 18 Jul 6, 2026
Copilot AI requested a review from vkarpov15 July 6, 2026 20:58
@vkarpov15
vkarpov15 marked this pull request as ready for review July 20, 2026 14:49
Copilot AI review requested due to automatic review settings July 20, 2026 14:49

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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

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

@vkarpov15
vkarpov15 merged commit d68da8b into master Jul 20, 2026
47 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