From d8bf2094b50d035b431a2f9f11fef6fe90f26d22 Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Fri, 15 Feb 2019 16:16:12 -0500 Subject: [PATCH] fix(sessions): enable sessions in OP_MSG Sessions information is not presently applied to OP_MSG messages because of a patch that was left out of the OP_MSG PR. The real fix for this is to merge all of the sessions-related code in our pool into the `command` wire protocol method, but that work shouldn't hold up sessions support today. --- lib/connection/pool.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/connection/pool.js b/lib/connection/pool.js index 8d905dadc..9dfbcfca1 100644 --- a/lib/connection/pool.js +++ b/lib/connection/pool.js @@ -1207,15 +1207,18 @@ Pool.prototype.write = function(command, options, cb) { } // decorate the commands with session-specific details + let commandDocument = command; if (command instanceof Query) { - if (command.query.$query) { - Object.assign(command.query.$query, sessionOptions); - } else { - Object.assign(command.query, sessionOptions); - } - } else { - Object.assign(command, sessionOptions); + commandDocument = command.query; + } else if (command instanceof Msg) { + commandDocument = command.command; } + + if (commandDocument.$query) { + commandDocument = commandDocument.$query; + } + + Object.assign(commandDocument, sessionOptions); } // If command monitoring is enabled we need to modify the callback here