streamlit: Infinite index.html requests causing high resource usage
Checklist
- I have searched the existing issues for similar issues.
- I added a very descriptive title to this issue.
- I have provided sufficient information below to help reproduce this issue.
Summary
I’m not sure if this issue originates from streamlit itself or the Streamlit-Authenticator component. However, after upgrading to streamlit==1.43.0, I suppose that any basic app using this custom component should encounter this problem :
Reproducible Code Example
# app.py
from pathlib import Path
import streamlit as st
import streamlit_authenticator as stauth # pip install streamlit-authenticator
import yaml
def load_config() -> dict:
"""Loads the authentication configuration from the YAML file."""
with Path("config.yaml").open() as file:
return yaml.safe_load(file)
def main() -> None:
"""Main function of the application."""
st.set_page_config(page_title="Authentication App", page_icon="🔒")
config = load_config()
authenticator = stauth.Authenticate(
credentials=config["credentials"],
cookie_name=config["cookie"]["name"],
key=config["cookie"]["key"],
cookie_expiry_days=config["cookie"]["expiry_days"],
preauthorized=config["preauthorized"]["emails"],
)
name, authentication_status, _username = authenticator.login("Login", "main")
if authentication_status is False:
st.error("Incorrect username or password")
elif authentication_status is None:
st.warning("Please enter your credentials")
else:
st.sidebar.title(f"Welcome {name}")
authenticator.logout("Logout", "sidebar")
st.title("Authentication App")
st.write("This content is only visible to authenticated users.")
if __name__ == "__main__":
main()
Steps To Reproduce
streamlit run app.py
Expected Behavior
No response
Current Behavior
No response
Is this a regression?
- Yes, this used to work in a previous version.
Debug info
- Streamlit version: 1.43.0
- Python version: 3.10
- Operating System: Windows 10
- Browser: Version 133.0.6943.142 (Official Build) (32-bit)
Additional Information
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 8
- Comments: 16
Commits related to this issue
- [fix] Fix custom component flickering (#10663) ## Describe your changes - Updates the width HOC to utilize `-1px` as a temporary width rather than not rendering the child component until the observe... — committed to annihilatorrrr/streamlit by lukasmasuch 2 years ago
- [fix] withCalculatedWidth fallback (#10672) ## Describe your changes - Includes missing change from https://github.com/streamlit/streamlit/pull/10663 - Adds unit tests ## GitHub Issue Link (if appl... — committed to streamlit/streamlit by sfc-gh-bnisco 2 years ago
- [fix] Fix custom component flickering (#10663) ## Describe your changes - Updates the width HOC to utilize `-1px` as a temporary width rather than not rendering the child component until the observe... — committed to streamlit/streamlit by lukasmasuch 2 years ago
- [fix] withCalculatedWidth fallback (#10672) ## Describe your changes - Includes missing change from https://github.com/streamlit/streamlit/pull/10663 - Adds unit tests ## GitHub Issue Link (if appl... — committed to streamlit/streamlit by sfc-gh-bnisco 2 years ago
- [fix] Fix custom component flickering (#10663) ## Describe your changes - Updates the width HOC to utilize `-1px` as a temporary width rather than not rendering the child component until the observe... — committed to streamlit/streamlit by lukasmasuch 2 years ago
- [fix] withCalculatedWidth fallback (#10672) ## Describe your changes - Includes missing change from https://github.com/streamlit/streamlit/pull/10663 - Adds unit tests ## GitHub Issue Link (if appl... — committed to streamlit/streamlit by sfc-gh-bnisco 2 years ago
- [fix] Fix custom component flickering (#10663) ## Describe your changes - Updates the width HOC to utilize `-1px` as a temporary width rather than not rendering the child component until the observe... — committed to akramsystems/streamlit by lukasmasuch 2 years ago
- [fix] withCalculatedWidth fallback (#10672) ## Describe your changes - Includes missing change from https://github.com/streamlit/streamlit/pull/10663 - Adds unit tests ## GitHub Issue Link (if appl... — committed to akramsystems/streamlit by sfc-gh-bnisco 2 years ago
I just installed
1.43.1.dev20250306and I confirm the flickering is gone. @lukasmasuch, you’re awesome. Thanks 😉@sfc-gh-lwilby, with
streamlit-authenticator==0.4.2(latest), the flickering issue occurs after the form’s submission. While it’s less severe than the pre-submit flickering seen withstreamlit-authenticator==0.2.1that I show in the provided .gif above, the issue still persists.After some debugging, I was able to reproduce the flickering using
streamlit-authenticator==0.2.1with any streamlit version later than1.42.2.dev20250217. It seems the issue starts with1.42.2.dev20250218and might be related to the hashlib changes made by #10413 but I could be completely wrong. Hopefully, this helps provide some insights for @mkhorasani and (if relevant) for you streamlit team.@sfc-gh-lwilby, I just switched to the official release. You made my week, team. Thanks 😉
@VERBOSE-01 the patch release including this fix is here https://pypi.org/project/streamlit/1.43.1/
Thanks! Also kudos to @sfc-gh-bnisco who did a big part of the work on this
Hi, this is the code for that specific page.
The end result is that you see the title jumping up and down.
I am also having this continuous reload issue on streamlit 1.43.0. However I am not using streamlit authenticator.
This happens on my pages that utilise the CookieManager from extra_streamlit_components
If I replace cookies = st.session_state.cookie_manager.get_all()
with
cookies = None
then the page no longer infinitly refreshes.