Chainlit WebSocket Issue on Hugging Face Spaces: Missing websockets in Requirements?

I started using Hugging Face Spaces just a few hours ago and noticed that my simple Chainlit app wasn’t working correctly. The app itself is straightforward—it simply returns whatever the user inputs. However, it seems the WebSocket communication isn’t functioning properly, so the responses don’t display as expected (see attached image).

After investigating, I found that specifying the websockets package in my requirements.txt file fixes the problem. With websockets installed, the responses show up correctly.

To help others see the difference, I created two repositories:

I also noticed that in some Spaces using Chainlit—where there is no issue—packages like google-genai automatically install websockets as a dependency.

On the other hand, when I searched for recently updated repositories, I found a few Spaces that seem to have the same issue. I hope this will help anyone facing similar problems.

Could there be something wrong with the websockets package included in the Docker image used by Hugging Face? If anyone has more details, I would really appreciate your insights.

1 Like

Similar issue?