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 :

Image

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

Most upvoted comments

I just installed 1.43.1.dev20250306 and 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 with streamlit-authenticator==0.2.1 that 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.1 with any streamlit version later than 1.42.2.dev20250217. It seems the issue starts with 1.42.2.dev20250218 and 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

@stefanverbeeck thank you for adding this information. Would you be able to post a reproducible code sample?

Hi, this is the code for that specific page.

The end result is that you see the title jumping up and down.

import streamlit as st
import extra_streamlit_components as stx


if "cookie_manager" not in st.session_state:
    # start the cookie manager
    st.session_state.cookie_manager = stx.CookieManager()

cookies = st.session_state.cookie_manager.get_all()

st.write("**Save/load Current filters**")

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.