Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions samples/frontend/src/components/WebhookStream.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,18 @@ export default function WebhookStream() {

es.onopen = () => setConnected(true)
es.onmessage = (event) => {
const raw = event.data?.trim()
if (!raw || raw === 'heartbeat') return
try {
const data = JSON.parse(event.data)
const data = JSON.parse(raw)
if (data.type === 'connected') return
setEvents((prev) => [{
timestamp: Date.now(),
type: data.type ?? 'unknown',
raw: JSON.stringify(data, null, 2)
}, ...prev])
} catch {
setEvents((prev) => [{
timestamp: Date.now(),
type: 'raw',
raw: event.data
}, ...prev])
// Skip non-JSON messages (heartbeats, etc.)
}
Comment on lines 32 to 34
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment mentions "heartbeats" but they are already filtered by the raw === 'heartbeat' check on line 23, so they never reach this catch block. Consider updating the comment to clarify:

Suggested change
} catch {
setEvents((prev) => [{
timestamp: Date.now(),
type: 'raw',
raw: event.data
}, ...prev])
// Skip non-JSON messages (heartbeats, etc.)
}
} catch {
// Discard unparseable SSE frames
}
Prompt To Fix With AI
This is a comment left during a code review.
Path: samples/frontend/src/components/WebhookStream.tsx
Line: 32-34

Comment:
The comment mentions "heartbeats" but they are already filtered by the `raw === 'heartbeat'` check on line 23, so they never reach this catch block. Consider updating the comment to clarify:

```suggestion
        } catch {
          // Discard unparseable SSE frames
        }
```

How can I resolve this? If you propose a fix, please make it concise.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

}
es.onerror = () => {
Expand Down
Loading