Skip to content

Commit e34e09c

Browse files
committed
fix (chat): resolving buffering issues (WIP)
1 parent 3aba442 commit e34e09c

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/client/components/ChatOverlay.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,15 @@ const ChatOverlay = ({ onClose }) => {
132132
while ((newlineIndex = buffer.indexOf("\n")) !== -1) {
133133
const line = buffer.slice(0, newlineIndex)
134134
buffer = buffer.slice(newlineIndex + 1)
135-
if (line.trim() === "") continue
135+
if (line.trim() === "") continue // Skip empty lines
136+
137+
// Log the raw line received from the stream
138+
console.log("[ChatStream] Received raw line:", line)
139+
136140
try {
137141
const parsed = JSON.parse(line)
142+
// Log the parsed JavaScript object
143+
console.log("[ChatStream] Parsed data:", parsed)
138144
if (parsed.type === "error") {
139145
toast.error(`An error occurred: ${parsed.message}`)
140146
continue

src/server/main/chat/routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ async def event_stream_generator():
5454
):
5555
if not event:
5656
continue
57+
logger.info(f"Streaming event to user {user_id}: {json.dumps(event)}")
5758
# yield as bytes and flush
5859
yield json.dumps(event) + "\n"
5960
except asyncio.CancelledError:

0 commit comments

Comments
 (0)