fix: processing page auto-redirect after file upload completes

Three fixes for the processing page not redirecting when status becomes "ended":

- Add useWebSockets to processing page so it receives STATUS events
- Remove OAuth2PasswordBearer from auth_none — broke WebSocket endpoints (500)
- Reconnect stale Redis in ws_manager when Celery worker reuses dead event loop
This commit is contained in:
Igor Loskutov
2026-02-11 15:53:21 -05:00
parent 8c2b720564
commit 2d81321733
3 changed files with 14 additions and 10 deletions

View File

@@ -1,11 +1,5 @@
from typing import Annotated
from fastapi import Depends
from fastapi.security import OAuth2PasswordBearer
from pydantic import BaseModel from pydantic import BaseModel
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token", auto_error=False)
class UserInfo(BaseModel): class UserInfo(BaseModel):
sub: str sub: str
@@ -15,13 +9,13 @@ class AccessTokenInfo(BaseModel):
pass pass
def authenticated(token: Annotated[str, Depends(oauth2_scheme)]): def authenticated():
return None return None
def current_user(token: Annotated[str, Depends(oauth2_scheme)]): def current_user():
return None return None
def current_user_optional(token: Annotated[str, Depends(oauth2_scheme)]): def current_user_optional():
return None return None

View File

@@ -48,7 +48,15 @@ class RedisPubSubManager:
if not self.redis_connection: if not self.redis_connection:
await self.connect() await self.connect()
message = json.dumps(message) message = json.dumps(message)
await self.redis_connection.publish(room_id, message) try:
await self.redis_connection.publish(room_id, message)
except RuntimeError:
# Celery workers run each task in a new event loop (asyncio.run),
# which closes the previous loop. Cached Redis connection is dead.
# Reconnect on the current loop and retry.
self.redis_connection = None
await self.connect()
await self.redis_connection.publish(room_id, message)
async def subscribe(self, room_id: str) -> redis.Redis: async def subscribe(self, room_id: str) -> redis.Redis:
await self.pubsub.subscribe(room_id) await self.pubsub.subscribe(room_id)

View File

@@ -11,6 +11,7 @@ import {
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
import { useTranscriptGet } from "../../../../lib/apiHooks"; import { useTranscriptGet } from "../../../../lib/apiHooks";
import { parseNonEmptyString } from "../../../../lib/utils"; import { parseNonEmptyString } from "../../../../lib/utils";
import { useWebSockets } from "../../useWebSockets";
type TranscriptProcessing = { type TranscriptProcessing = {
params: Promise<{ params: Promise<{
@@ -24,6 +25,7 @@ export default function TranscriptProcessing(details: TranscriptProcessing) {
const router = useRouter(); const router = useRouter();
const transcript = useTranscriptGet(transcriptId); const transcript = useTranscriptGet(transcriptId);
useWebSockets(transcriptId);
useEffect(() => { useEffect(() => {
const status = transcript.data?.status; const status = transcript.data?.status;