mapbox-gl-js version
v3.12.0
Browser and version
Chrome Version 152.0.7939.3 (Official Build) dev (arm64)
Expected behavior
removeSource() completes without throwing, or throws before the source is removed (so callers can handle a true failure)
Actual behavior
Source is removed successfully, then _updateTerrain() throws — leaving callers unable to distinguish a real removal failure from this internal bookkeeping error
Calling map.removeSource(sourceId) throws a TypeError: Cannot read properties of undefined (reading 'get') in certain conditions. The throw originates from the internal _updateTerrain() call that runs after this.style.removeSource(e) inside removeSource. By the time the error throws, the source has already been removed from the style, so the error is benign — but it disrupts any code running in the same call stack after removeSource.
Link to the demonstration
No response
Steps to trigger the unexpected behavior
- Add a GeoJSON source
- Add a terrain to the map
- Remove the source — map.removeSource(sourceId) throws
Relevant log output
TypeError: Cannot read properties of undefined (reading 'get')
at sn.update (mapbox-gl.js)
at Map._updateTerrain (mapbox-gl.js)
at Map.removeSource (mapbox-gl.js)
mapbox-gl-js version
v3.12.0
Browser and version
Chrome Version 152.0.7939.3 (Official Build) dev (arm64)
Expected behavior
removeSource()completes without throwing, or throws before the source is removed (so callers can handle a true failure)Actual behavior
Source is removed successfully, then
_updateTerrain()throws — leaving callers unable to distinguish a real removal failure from this internal bookkeeping errorCalling
map.removeSource(sourceId)throws aTypeError: Cannot read properties of undefined (reading 'get')in certain conditions. The throw originates from the internal_updateTerrain()call that runs afterthis.style.removeSource(e)insideremoveSource. By the time the error throws, the source has already been removed from the style, so the error is benign — but it disrupts any code running in the same call stack afterremoveSource.Link to the demonstration
No response
Steps to trigger the unexpected behavior
Relevant log output