diff --git a/packages/protocol-parser/src/parsers/buffer-preparsed.ts b/packages/protocol-parser/src/parsers/buffer-preparsed.ts index e1ee9fbd20..c0cd54aa33 100644 --- a/packages/protocol-parser/src/parsers/buffer-preparsed.ts +++ b/packages/protocol-parser/src/parsers/buffer-preparsed.ts @@ -12,7 +12,8 @@ export default class PreparsedLengthBuffer implements P if (cursor.subByteOffset > 0) throw new Error('Cross byte value are not supported'); - const result = buffer.subarray(cursor.offset, cursor.offset + Number(message[this.lengthProperty])); + const length = Number(message[this.lengthProperty]); + const result = buffer.subarray(cursor.offset, cursor.offset + length); cursor.offset += length; return result; }