From 0fbe1d439b1e42bd5e621dc0b63aa8312f0586c0 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Thu, 11 Jul 2024 13:02:18 +0300 Subject: [PATCH] Fix ChangeStream.close to return a Promise like the driver Client code that calls stream.close().then(...) fails with TypeError, since mongoose close() returns undefined. --- lib/cursor/changeStream.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/cursor/changeStream.js b/lib/cursor/changeStream.js index 64fcbf22ab9..ec5cac5705f 100644 --- a/lib/cursor/changeStream.js +++ b/lib/cursor/changeStream.js @@ -141,8 +141,9 @@ class ChangeStream extends EventEmitter { close() { this.closed = true; if (this.driverChangeStream) { - this.driverChangeStream.close(); + return this.driverChangeStream.close(); } + return Promise.resolve(); } }