-
Notifications
You must be signed in to change notification settings - Fork 568
[Bug]: WebSocket clients ignore Node's global WebSocket in ESM builds #4846
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't workingjavascriptPull requests that update javascript codePull requests that update javascript codepriority:mediumFor bugs, a serious source of annoyance, but not blocking a large number of users.For bugs, a serious source of annoyance, but not blocking a large number of users.ready-for-devIssue meets development readiness criteriaIssue meets development readiness criteriarelease-note-requiredPR requires explicit release-note coverage for behavioral or default changesPR requires explicit release-note coverage for behavioral or default changes
Description
Activity
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingjavascriptPull requests that update javascript codePull requests that update javascript codepriority:mediumFor bugs, a serious source of annoyance, but not blocking a large number of users.For bugs, a serious source of annoyance, but not blocking a large number of users.ready-for-devIssue meets development readiness criteriaIssue meets development readiness criteriarelease-note-requiredPR requires explicit release-note coverage for behavioral or default changesPR requires explicit release-note coverage for behavioral or default changes
Is there an existing issue for the same bug?
Bug Description
The package is emitted as ESM, and Node 22 provides a standards-compatible globalThis.WebSocket.
The conversation and bash event clients only check window.WebSocket, then attempt require("ws"). Since require is unavailable in ESM, starting either client reports that no WebSocket implementation is available.
Expected Behavior
The TypeScript WebSocket callback clients use Node's global WebSocket constructor when globalThis.WebSocket is available.
Actual Behavior
The error callback receives "WebSocket implementation not available", even though globalThis.WebSocket exists. This is reproducible after running uv sync --dev and building the TypeScript package.
Steps to Reproduce
Example:
node --input-type=module -e "const {WebSocketCallbackClient}=await import('./dist/events/websocket-client.js'); const client=new WebSocketCallbackClient({host:'http://127.0.0.1:9',conversationId:'test',callback:()=>{},onError:console.error}); client.start(); client.stop()"Acceptance Criteria
Installation Method
uv sync --dev; npm ci in clients/typescript
If you selected "Other", please specify
No response
SDK Version
Current main branch
Version Confirmation
Python Version
No response
Model Name (if applicable)
No response
Operating System
Linux
Logs and Error Messages
WebSocket implementation not available
Minimal Code Sample
node --input-type=module -e "const {WebSocketCallbackClient}=await import('./dist/events/websocket-client.js'); const client=new WebSocketCallbackClient({host:'http://127.0.0.1:9',conversationId:'test',callback:()=>{},onError:console.error}); client.start(); client.stop()"Screenshots and Additional Context
this is the issue backing #4799