Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError: WebSocket is not defined (6.1.0) #3692

Closed
krismrp opened this issue May 12, 2018 · 9 comments
Closed

ReferenceError: WebSocket is not defined (6.1.0) #3692

krismrp opened this issue May 12, 2018 · 9 comments

Comments

@krismrp
Copy link

krismrp commented May 12, 2018

RxJS version: 6.1.0

Code to reproduce:

const { webSocket } = require("rxjs/websocket");
const w3cwebsocket = require("websocket").w3cwebsocket;

webSocket({
  url: 'ws://foobar',
  WebSocketCtor: w3cwebsocket
});

Expected behavior:
Should not error when given a WebSocket constructor.

Actual behavior:

            config.WebSocketCtor = WebSocket;
                                   ^

ReferenceError: WebSocket is not defined
    at new WebSocketSubject (E:\CODE\Github\[REMOVED]\node_modules\rxjs\internal\observable\dom\WebSocketSubject.js:49:36)
    at webSocket (E:\CODE\Github\[REMOVED]\node_modules\rxjs\internal\observable\dom\webSocket.js:43:12)
    at Object.<anonymous> (E:\CODE\Github\[REMOVED]\index.js:4:1)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
    at Function.Module.runMain (module.js:665:10)
    at startup (bootstrap_node.js:201:16)
@waitingsong
Copy link

try
const websocket = require('rxjs/websocket');

@krismrp
Copy link
Author

krismrp commented May 13, 2018

I still get the same error message, can you confirm that the above code works for you?

@waitingsong
Copy link

yes. it works .

@krismrp
Copy link
Author

krismrp commented May 14, 2018

Hm, still the same issue. Didn't have any problems with 5.x version.

@bbonnet
Copy link
Contributor

bbonnet commented May 14, 2018

I think that should fix the issue #3694
@krismrp Can you help verify please?

@fuocor
Copy link

fuocor commented May 14, 2018

Happens in Node because the constructor does not check if WebSocket exists before assigning it to the config

@krismrp
Copy link
Author

krismrp commented May 15, 2018

@bbonnet I'll gladly do that, but how exactly? I was able to add your pull request with Yarn, but everything went downhill from there. 😕

@bbonnet
Copy link
Contributor

bbonnet commented May 17, 2018

@krismrp Did you get a specific error when everything went downhill? lol I think you should just be able to pin to that branch and pull it down into your app but I'm not 100% sure

@benlesh
Copy link
Member

benlesh commented May 21, 2018

Yes, #3694 should fix this. Closing this issue.

@benlesh benlesh closed this as completed May 21, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jun 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants