Skip to content

Fix the WebSocket event checks in the WebSockets guide - #335

Merged
duharry0915 merged 1 commit into
mainfrom
claude/ws-event-type-check
Oct 21, 2026
Merged

duharry0915 merged 1 commit into
mainfrom
claude/ws-event-type-check

Conversation

@duharry0915

Copy link
Copy Markdown
Collaborator

Why

The TypeScript examples in fern/pages/websockets.mdx branched on event.type === "message_received". The server sends every event with type: "event" and puts the kind in event_type (eventType in the TypeScript SDK). So those branches never ran: a reader who copied the guide never saw an email arrive.

The Basic Usage example also read event.message.from_, which is the Python name; the TypeScript SDK calls it from.

Change

  • The four TypeScript examples match event.type === "event" && event.eventType === "message.received", as the WebSockets quickstart and the x402 / MPP pages already do: Basic Usage, React, Error Handling, and Copy for Cursor / Claude.
  • They drop the handler annotations that named a single event type.
  • The event tables list the value a handler compares against (subscribed, message.received, domain.verified, calendar.event.created, ...). They used to list the SDK's message names (message_received, ...). One line explains type vs event_type.
  • The message-properties table gives the TypeScript sender field as from.

Verification

The corrected TypeScript snippets type-check against the Node SDK's generated types (tsc --noEmit).

Not changed

fern/changelog/2025-07-20.mdx still shows event.type === "message.received". It's a dated announcement, so it's left as published.

🤖 Generated with Claude Code

Every event frame has type "event"; the guide's TypeScript examples matched
type === "message_received", which never fires. Match on eventType, like the
quickstart, and read the sender as message.from. The event tables now list
the type / event_type values a handler compares against.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

@duharry0915
duharry0915 merged commit 7b4c75d into main Oct 21, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants