Use Buffer.byteLength instead of msg.length