demo: polyfill global WebSocket for Node (fixes register-test.mjs) #3

Merged
mohlec merged 1 commit from fix/node-websocket-polyfill into main 2026-07-15 20:56:06 +00:00
Owner

register-test.mjs crashed with ReferenceError: WebSocket is not defined on plain Node -- SIP.js's transport expects a global WebSocket, which only browsers provide natively. The script never actually tested anything before this fix.

Found while running the first real test against a FreePBX extension for task #1. Added ws as a devDependency + polyfill globalThis.WebSocket. Confirmed working against both a dead public demo endpoint (now times out correctly) and the real FreePBX target (now gets a genuine TCP connection-refused, diagnosing an actual PBX-side gap instead of a meaningless client crash).

register-test.mjs crashed with ReferenceError: WebSocket is not defined on plain Node -- SIP.js's transport expects a global WebSocket, which only browsers provide natively. The script never actually tested anything before this fix. Found while running the first real test against a FreePBX extension for task #1. Added ws as a devDependency + polyfill globalThis.WebSocket. Confirmed working against both a dead public demo endpoint (now times out correctly) and the real FreePBX target (now gets a genuine TCP connection-refused, diagnosing an actual PBX-side gap instead of a meaningless client crash).
demo: polyfill global WebSocket for Node (fixes register-test.mjs)
All checks were successful
Build slash-sip-client / build (pull_request) Successful in 5s
4cd4540c4e
Node has no native global WebSocket -- that's a browser API SIP.js's
transport expects to exist unconditionally. Running register-test.mjs
on plain Node failed immediately with 'ReferenceError: WebSocket is
not defined', regardless of whether the target SIP server was even
reachable -- meaning the script never actually tested anything.

Found while running the first real test against a FreePBX extension
(task #1): added 'ws' as a devDependency and polyfill globalThis.WebSocket
before the SoftphoneLine import. Confirmed working both against a dead
public demo endpoint (now correctly times out instead of crashing) and
the real FreePBX target (now gets a real TCP-level connection refused,
diagnosing an actual PBX-side gap -- port 8089 WSS transport not yet
enabled -- instead of a meaningless client-side crash).
mohlec merged commit 6fe9ad648a into main 2026-07-15 20:56:06 +00:00
mohlec deleted branch fix/node-websocket-polyfill 2026-07-15 20:56:06 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
slash/slash-sip-client!3
No description provided.