Checklist
Summary
When using st.altair_chart() with sidebar widgets, a race condition occurs during app reruns that causes Altair charts to fail with the error Uncaught (in promise) Error: Unrecognized data set: <hash>. The error appears in the browser console, chart rendering is interrupted showing a blank x-axis, and the chart only renders properly when the mouse is moved.

Reproducible Code Example
import streamlit as st
import altair as alt
import pandas as pd
import numpy as np
# Add 10 sidebar widgets, each with 1000 different options.
for i in range(10):
st.sidebar.selectbox(
f"Widget {i}",
[f"Option {j}" for j in range(1000)],
)
# Generate sample data
n_points = 8000
data = pd.DataFrame({
'x': np.random.randn(n_points),
'y': np.random.randn(n_points),
'category': np.random.choice(['A', 'B', 'C'], n_points),
})
# Line chart
lines = alt.Chart(data).mark_line().encode(
x=alt.X('x:Q'),
y=alt.Y('y:Q'),
color=alt.Color('category:N'),
)
# 10 text overlay labels
labels = alt.Chart(data.head(10)).mark_text().encode(
x=alt.X('x:Q'),
y=alt.Y('y:Q'),
text=alt.Text('category:N'),
)
st.altair_chart(lines + labels, use_container_width=True)
st.button("rerun")
Steps To Reproduce
- Run the above code snippet with
streamlit run ...
- Click the "rerun" button repeatedly
- Open browser developer console to see the error
- Observe the chart behavior
Expected Behavior
The Altair chart should render correctly on every rerun without errors, displaying the line chart with text labels consistently.
Current Behavior
- Error in browser console:
Uncaught (in promise) Error: Unrecognized data set: 1760930fca8bdd09f674f91f30b801ed (hash varies)
- Visual symptoms:
- Chart rendering is interrupted
- Blank x-axis is displayed
- Chart only renders properly when the mouse is moved over the chart area (probably firing chart re-render)
- Reproducibility: The bug is non-deterministic but on my system it can be reproduced reliably with the data set size and number of widgets in the example code
Is this a regression?
Debug info
- Streamlit version: 1.46.1
- Python version: 3.13.2
- Altair version: 5.5.0
- OS version: macOS (Darwin)
- Browser version: Chrome (error appears in browser console)
Additional Information
Investigation of the Vega-Lite source before and after hitting rerun shows that the hash mentioned in the error corresponds to the outgoing (old) dataset. This indicates a race condition where the "old" plot attempts to render after its dataset has already been removed from the Vega-Lite data registry.
The error can also happen for non-layered charts, but in that case the chart renders as opposed to blanking out.
- The error hash corresponds to a Vega-Lite dataset identifier
- The issue appears to be a race condition in the chart update lifecycle
- The bug is reliably reproducible with larger datasets and multiple sidebar widgets
- Removing the sidebar widgets reduces the frequency of the problem to the point it can be hard to reproduce
Checklist
Summary
When using
st.altair_chart()with sidebar widgets, a race condition occurs during app reruns that causes Altair charts to fail with the errorUncaught (in promise) Error: Unrecognized data set: <hash>. The error appears in the browser console, chart rendering is interrupted showing a blank x-axis, and the chart only renders properly when the mouse is moved.Reproducible Code Example
Steps To Reproduce
streamlit run ...Expected Behavior
The Altair chart should render correctly on every rerun without errors, displaying the line chart with text labels consistently.
Current Behavior
Uncaught (in promise) Error: Unrecognized data set: 1760930fca8bdd09f674f91f30b801ed(hash varies)Is this a regression?
Debug info
Additional Information
Investigation of the Vega-Lite source before and after hitting rerun shows that the hash mentioned in the error corresponds to the outgoing (old) dataset. This indicates a race condition where the "old" plot attempts to render after its dataset has already been removed from the Vega-Lite data registry.
The error can also happen for non-layered charts, but in that case the chart renders as opposed to blanking out.