Skip to content

Commit 8bb2c10

Browse files
pengyingclaude
andcommitted
fix(samples): filter out heartbeat messages from webhook stream UI
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent dd4347f commit 8bb2c10

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

samples/frontend/src/components/WebhookStream.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,18 @@ export default function WebhookStream() {
1919

2020
es.onopen = () => setConnected(true)
2121
es.onmessage = (event) => {
22+
const raw = event.data?.trim()
23+
if (!raw || raw === 'heartbeat') return
2224
try {
23-
const data = JSON.parse(event.data)
25+
const data = JSON.parse(raw)
2426
if (data.type === 'connected') return
2527
setEvents((prev) => [{
2628
timestamp: Date.now(),
2729
type: data.type ?? 'unknown',
2830
raw: JSON.stringify(data, null, 2)
2931
}, ...prev])
3032
} catch {
31-
setEvents((prev) => [{
32-
timestamp: Date.now(),
33-
type: 'raw',
34-
raw: event.data
35-
}, ...prev])
33+
// Skip non-JSON messages (heartbeats, etc.)
3634
}
3735
}
3836
es.onerror = () => {

0 commit comments

Comments
 (0)