Deleting CZML with callbacks set

I want to delete a CZML with callbacks set.
For polylines, it is not possible to delete.
In the case of ellipsoid, it was possible to delete it.

How do you handle the case of a polyline?

Polyline code


const viewer = new Cesium.Viewer("cesiumContainer");

var DataSource = new Cesium.CzmlDataSource();
let loadedPromise =  DataSource.load("../../SampleData/simple.czml");
viewer.dataSources.add(DataSource);

var entities = [];

Sandcastle.addToolbarButton("Remove Polyline", function () {
  let removeData = viewer.dataSources.getByName("document_name");
  viewer.dataSources.remove(removeData[0]);
});

  let doc = {
    id: "document",
    name: "document_name",
    version: "1.0",
  };

  entities.push(doc);

  const entity = {
    id: "POLYLINE",
    name: "polyline",
    polyline: {
      positions: {
        cartesian : [-3499152.949946318, 4532113.931097018, 2800650.164501517,3499152.949946318,4532113.931097018,2800650.164501517],
      },
      width: 1.0,
      material: {
        color: {
          rgba: [255, 255, 255, 255]
        },
      },
arcType: "NONE",
    }
  };

entities.push(entity);

loadedPromise.then(function () {
  
  let dataSourcePromise = Cesium.CzmlDataSource.load(entities);

  viewer.dataSources.add(dataSourcePromise).then(
    function(dataSource){
      let entity1 = DataSource.entities.getById("Satellite/Geoeye1");
      let entity2 = DataSource.entities.getById("Satellite/Molniya_1-92");
      let entity3 = dataSource.entities.getById("POLYLINE");

      entity3.polyline.positions = new Cesium.CallbackProperty(function () {

        let time = viewer.clock.currentTime;
        let pos1 = entity1.position.getValue(time);
        let pos2 = entity2.position.getValue(time);
        let arr = [];
        arr.push( pos1 );
        arr.push( pos2 );

        return arr;

      }, false);

        return dataSource;
    }
  );
});

Screen

Error when deleting a polyline

Ellipsoid code


const viewer = new Cesium.Viewer("cesiumContainer");

var DataSource = new Cesium.CzmlDataSource();
let loadedPromise =  DataSource.load("../../SampleData/simple.czml");
viewer.dataSources.add(DataSource);

var entities = [];

Sandcastle.addToolbarButton("Remove Ellipsoid", function () {
  let removeData = viewer.dataSources.getByName("ellipsoid_czml");
  viewer.dataSources.remove(removeData[0]);
});

let doc = {
  id: "document",
  name: "ellipsoid_czml",
  version: "1.0",
};

entities.push(doc);

const entity = {
  id: "ELLIPSOID",
  name: "ellipsoid",
  position: {
    cartesian : [-3499152.949946318, 4532113.931097018, 2800650.164501517]
  },
  orientation: undefined,				
  ellipsoid: {
  radii: {
    cartesian: [ 1000000, 1000000, 1000000 ]
  },
    material: {
      solidColor: {
        color: {
          rgba: [255,255,255,255]
        }
      }
    },
  outline: true,
  }
};

entities.push(entity);

loadedPromise.then(function () {

  let dataSourcePromise = Cesium.CzmlDataSource.load(entities);

  viewer.dataSources.add(dataSourcePromise).then(
    function(dataSource){
      let entity1 = DataSource.entities.getById("Satellite/Geoeye1");
      let entity2 = dataSource.entities.getById("ELLIPSOID");

      entity2.position = new Cesium.CallbackProperty(function () {
      let time = viewer.clock.currentTime;
      let pos = entity1.position.getValue(time);
      
      return pos;

      }, false);

    return dataSource;
    }
  );
});