fix: do not double JSON encode

ref: N25B-242
This commit is contained in:
Twirre Meulenbelt
2025-11-05 16:35:12 +01:00
parent 9e7119481c
commit f12a57248a

View File

@@ -3,7 +3,6 @@ import logging
import zmq
from fastapi import APIRouter
from fastapi.responses import StreamingResponse
from pyjabber.server_parameters import json
from zmq.asyncio import Context
from control_backend.core.config import settings
@@ -15,6 +14,8 @@ router = APIRouter()
@router.get("/logs/stream")
async def log_stream():
# DO NOT LOG in this function, or you'll get recursive logs. If you need it for debugging, use
# the built-in `print()`
context = Context.instance()
socket = context.socket(zmq.SUB)
@@ -27,7 +28,6 @@ async def log_stream():
while True:
_, message = await socket.recv_multipart()
message = message.decode().strip()
json_data = json.dumps(message)
yield f"data: {json_data}\n\n"
yield f"data: {message}\n\n"
return StreamingResponse(gen(), media_type="text/event-stream")