Skip to content

Commit

Permalink
fix(compression): recalculate opcode after determine OP_COMPRESSED
Browse files Browse the repository at this point in the history
  • Loading branch information
mbroadst committed Nov 12, 2019
1 parent 713fa38 commit 022f51b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/core/cmap/message_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function processMessage(stream, message, callback) {
opCode: message.readInt32LE(12)
};

const ResponseType = messageHeader.opCode === OP_MSG ? BinMsg : Response;
let ResponseType = messageHeader.opCode === OP_MSG ? BinMsg : Response;
const responseOptions = stream.responseOptions;
if (messageHeader.opCode !== OP_COMPRESSED) {
const messageBody = message.slice(MESSAGE_HEADER_SIZE);
Expand All @@ -150,6 +150,8 @@ function processMessage(stream, message, callback) {
const compressorID = message[MESSAGE_HEADER_SIZE + 8];
const compressedBuffer = message.slice(MESSAGE_HEADER_SIZE + 9);

// recalculate based on wrapped opcode
ResponseType = messageHeader.opCode === OP_MSG ? BinMsg : Response;
decompress(compressorID, compressedBuffer, (err, messageBody) => {
if (err) {
callback(err);
Expand Down

0 comments on commit 022f51b

Please sign in to comment.