The frontend should now automatically refresh the lobby state after the server restart, so the bot join request should succeed instead of getting a 404 error.

The key improvement is that when the WebSocket reconnects after a server restart, the frontend will automatically:

Detect that it's reconnecting (not an initial connection)
Clear the stale lobby state
Trigger a lobby refresh to get the current lobby ID
Use the fresh lobby ID for subsequent bot join requests
This ensures that bot join requests always use the current, valid lobby ID even after server restarts.
This commit is contained in:
James Ketr 2025-09-05 12:37:10 -07:00
parent 215926de88
commit 64c5d8c590
2 changed files with 8 additions and 1 deletions

View File

@ -44,6 +44,13 @@ const LobbyView: React.FC<LobbyProps> = (props: LobbyProps) => {
const { sendJsonMessage, lastJsonMessage, readyState } = useWebSocket(socketUrl, {
onOpen: () => {
console.log("app - WebSocket connection opened.");
// If we had a previous reconnect attempt (meaning we lost connection),
// refresh the lobby to get the current lobby ID
if (reconnectAttempt > 0 && lobby && lobbyName) {
console.log("app - WebSocket reconnected after connection loss, refreshing lobby state");
setLobby(null);
setShouldRetryLobby(true);
}
setReconnectAttempt(0);
},
onClose: () => {

View File

@ -1,4 +1,4 @@
"""Bot Provider Management"""
"""Bot Provider Management - Test fix for stale lobby IDs after restart"""
import os
import time
import uuid