Skip to content

WebSocket not correctly polyfilled #615

@saba-abi

Description

@saba-abi

In https://github.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-js/blob/master/src/SignalingClient.ts#L151

this.websocket = new (WebSocket || require('ws'))(signedURL);

When WebSocket is not defined, e.g. in Node.js, you will get a runtime error:

"ReferenceError: WebSocket is not defined"

The correct way to polyfill this would be:

const WS = (typeof WebSocket !== 'undefined') ? WebSocket : require('ws');
this.websocket = new WS(signedURL);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions