# An error occurred: viewer.dataSources.removeAll()

**URL:** <https://community.cesium.com/t/an-error-occurred-viewer-datasources-removeall/4932>\
**Category:** CesiumJS\
**Created:** [December 17, 2016, 3:05pm UTC](https://community.cesium.com/t/an-error-occurred-viewer-datasources-removeall/4932 "2016-12-17T15:05:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![insh](https://avatars.discourse-cdn.com/v4/letter/i/ea5d25/32.png) [@insh](https://community.cesium.com/u/insh)\
**Post date:** [December 17, 2016, 3:05pm UTC](https://community.cesium.com/t/an-error-occurred-viewer-datasources-removeall/4932/1 "2016-12-17T15:05:40Z")

</div>

Hi,  
I am very confused now. When I try to remove all the czml datasources by using “viewer.dataSources.removeAll()”, there’s an error saying below.

And this error occurs when viewer.dataSources.length\>1, meaning that when I add one single czml data file, the method viewer.dataSources.removeAll() work well.

However when I load more czml files and then remove them, there always comes out the Error about the “length” property.

I’ve tried many solutions and I’m really very upset because of this problem.

Could anyone help me out to find a solution to solve this problem? I am really very grateful for your help.

[![](https://lh3.googleusercontent.com/-L9hpPmXsfZE/WFVRiTdpGEI/AAAAAAAAADY/YAU_V7tEe4o0kj5U1z54bo00yeMEIximwCLcB/s1600/360%25E6%2588%25AA%25E5%259B%25BE20161217225140408.jpg)](https://lh3.googleusercontent.com/-L9hpPmXsfZE/WFVRiTdpGEI/AAAAAAAAADY/YAU_V7tEe4o0kj5U1z54bo00yeMEIximwCLcB/s1600/360%25E6%2588%25AA%25E5%259B%25BE20161217225140408.jpg)

---

<div class="post-metadata">

**Author:** ![hannah](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/hannah/32/4509_2.png) [@hannah](https://community.cesium.com/u/hannah)\
**Post date:** [December 19, 2016, 3:46pm UTC](https://community.cesium.com/t/an-error-occurred-viewer-datasources-removeall/4932/2 "2016-12-19T15:46:14Z")

</div>

Hello,

I haven’t seen this error before. Could you put together a [Sandcastle](http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Hello%20World.html&label=Showcases) example to reproduce this problem?

Thanks,

Hannah
