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

Uncaught TypeError: WebSocketServer is not a constructor in browser w/ webpack #62

Closed
EzraWeller opened this issue Jan 10, 2020 · 4 comments

Comments

@EzraWeller
Copy link

We're working on a web app using Mithril.js and webpack. Currently getting this error: Uncaught TypeError: WebSocketServer is not a constructor when trying

const WebSocketServer = require('rpc-websockets').Server
const server = new WebSocketServer({port, host})

Locally, the rpc-websocket object looks like:
{ Server: [Getter], Client: [Function: Client] }

In the browser, I get:
{__esModule: true, Client: ƒ} (no Server)

@mkozjak
Copy link
Member

mkozjak commented Jan 10, 2020

Hi, @EzraWeller, does it work with rpc-websockets version 4.x as expected?

@EzraWeller
Copy link
Author

EzraWeller commented Jan 10, 2020

Seems to be the same problem using both ^4.6.1 and the latest.

Edit: Webpack version ^4.41.5 if that helps.

@EzraWeller
Copy link
Author

So, we didn't solve this exactly, but we think the answer is pretty simple: we were trying to create a websocket server inside the browser, which is why the option wasn't available.

@mkozjak
Copy link
Member

mkozjak commented Jan 12, 2020

@EzraWeller: Thanks for the info! Should we update the docs or the api itself to make this more clear? Have any opinions on that?

@mkozjak mkozjak closed this as completed Jan 17, 2020
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

No branches or pull requests

2 participants