Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
fix(sessions): enable sessions in OP_MSG
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mbroadst committed Feb 16, 2019
1 parent d6edd76 commit d8bf209
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/connection/pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d8bf209

Please sign in to comment.