All attribute lists must have the same number of attributes. Error

My code:

function renderGeometry(data, divisions, extrusion) {
  try{
    var zValues = data.zValues;
    var bbox = data.bbox;

    var minx = bbox[0];
    var miny = bbox[1];
    var maxx = bbox[2];
    var maxy = bbox[3];

    var viewer = Georbis.getWorlds().toJS().MAIN_WORLD.cesiumViewer;
    // viewer.scene.globe.enableLighting = true;
    var scene = viewer.scene;

    var cols = divisions;
    var incr = (maxx - minx) / cols;

    var rows = Math.floor((maxy - miny) / incr);
    var pos = ;
    var index = ;

    var co = 0;

    for (var i = 0; i < rows; i++) {
        for (var j = 0; j < cols; j++) {
            var currX = minx + (j * incr);
            var currY = miny + (i * incr);
            pos.push(currX);
            pos.push(currY);
            var zval = zValues[co++];
            var height = parseFloat(extrusion * zval + BATHYMETRY_OFFSET);
            pos.push(height);
            if (i < (rows - 1)) {
                index.push((i * cols) + j);
                index.push(((i + 1) * cols) + j);
                if (j == (cols - 1)) {
                    for (var k = 0; k < cols; k++) {
                        index.push(((i + 1) * cols) + j - k);
                        if (k != (cols - 1)) {
                            index.push(((i + 1) * cols) + j - k - 1);
                        } else {
                            index.push(((i + 1) * cols) + j - k);
                        }
                    }
                }
            }
        }
    }

    var array = Cesium.Cartesian3.fromDegreesArrayHeights(pos);

    var positions = new Float64Array(pos.length);
    var colorArr = new Uint8Array(4 * pos.length / 3);
    var count = 0;
    var colorCount = 0;

    for (var arr of array) {
        positions[count++] = parseFloat(arr.x);
        positions[count++] = parseFloat(arr.y);
        positions[count++] = parseFloat(arr.z);
        colorArr[colorCount] = data.colors[colorCount];
        colorCount++;
        colorArr[colorCount] = data.colors[colorCount];
        colorCount++;
        colorArr[colorCount] = data.colors[colorCount];
        colorCount++;
        colorArr[colorCount] = data.colors[colorCount];
        colorCount++;
    }

    if(positions.length/3 != colorArr.length/4)throw new Error("colorArray should have same length as vertex array");
    var geometry2 = new Cesium.Geometry({
        attributes: {
            position: new Cesium.GeometryAttribute({
                componentDatatype: Cesium.ComponentDatatype.DOUBLE,
                componentsPerAttribute: 3,
                values: positions
            }),
            color: new Cesium.GeometryAttribute({
                componentDatatype: Cesium.ComponentDatatype.UNSIGNED_BYTE,
                componentsPerAttribute: 4,
                normalize: true,
                values: colorArr
            })
        },
        indices: new Uint32Array(index),
        primitiveType: Cesium.PrimitiveType.TRIANGLE_STRIP,
        boundingSphere: Cesium.BoundingSphere.fromVertices(positions)
    });

    geometry2 = Cesium.GeometryPipeline.toWireframe(geometry2);
    //geometry2 = Cesium.GeometryPipeline.computeNormal(geometry2);

    var ellipsoidInstance = new Cesium.GeometryInstance({
        geometry: geometry2,
        id: 'ellipsoid'
    });

    var surfacePrimitive = new Cesium.Primitive({
        geometryInstances: ellipsoidInstance,
        asynchronous: false,
        appearance: new Cesium.PerInstanceColorAppearance({
            flat: true,
            translucent: true
        })
    });

    scene.primitives.add(surfacePrimitive);
    return surfacePrimitive;
    }catch(error){
      console.log("renderGeometry Error:",error);
    }
}

Error:

An error occurred while rendering. Rendering has stopped.
undefined
DeveloperError: All attribute lists must have the same number of attributes.
Error
    at new DeveloperError (eval at module.exports (webpack-internal:///./node_modules/script-loader/addScript.js), <anonymous>:540:19)
    at Function.Geometry.computeNumberOfVertices (eval at module.exports (webpack-internal:///./node_modules/script-loader/addScript.js), <anonymous>:17454:27)
    at updateGeometryAfterSplit (eval at module.exports (webpack-internal:///./node_modules/script-loader/addScript.js), <anonymous>:36727:41)
    at updateInstanceAfterSplit (eval at module.exports (webpack-internal:///./node_modules/script-loader/addScript.js), <anonymous>:36767:24)
    at splitLongitudeLines (eval at module.exports (webpack-internal:///./node_modules/script-loader/addScript.js), <anonymous>:37104:9)
    at Object.GeometryPipeline.splitLongitude (eval at module.exports (webpack-internal:///./node_modules/script-loader/addScript.js), <anonymous>:37414:17)
    at geometryPipeline (eval at module.exports (webpack-internal:///./node_modules/script-loader/addScript.js), <anonymous>:97209:38)
    at Object.PrimitivePipeline.combineGeometry (eval at module.exports (webpack-internal:///./node_modules/script-loader/addScript.js), <anonymous>:97353:26)
    at loadSynchronous (eval at module.exports (webpack-internal:///./node_modules/script-loader/addScript.js), <anonymous>:99164:40)
    at Primitive.update (eval at module.exports (webpack-internal:///./node_modules/script-loader/addScript.js), <anonymous>:99714:17)

It’s strange that you’d be getting that error and this line wouldn’t be catching it:

if(positions.length/3 != colorArr.length/4)throw new Error(“colorArray should have same length as vertex array”);

``

You can see this is exactly the check the engine makes:

Can you print out those two numbers? And then perhaps if you’re using the unminified source you can add a print in that Geometry.js function to see which attribute it’s complaining about.