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

Error: ws does not work in the browser. Browser clients must use the native WebSocket object #1

Closed
fanksy opened this issue May 27, 2024 · 3 comments

Comments

@fanksy
Copy link

fanksy commented May 27, 2024

I used puppeteer to connect to the browser websocket , and an error occurred.

Please check this.

this is related issue.
perawallet/connect#101

I added "global.WebSocket": "globalThis.WebSocket", but it didn't work.

Error: ws does not work in the browser. Browser clients must use the native WebSocket object
    at new sfA (/Users/nolan/Work/JsProjects/electron-forge-react-vite-boilerplate/.vite/build/main-b0efc4c7.js:548:6313)
    at /Users/nolan/Work/JsProjects/electron-forge-react-vite-boilerplate/.vite/build/main-b0efc4c7.js:552:427
    at new Promise (<anonymous>)
    at ML.create (/Users/nolan/Work/JsProjects/electron-forge-react-vite-boilerplate/.vite/build/main-b0efc4c7.js:552:399)
    at lfA.createCdpSocketConnection (/Users/nolan/Work/JsProjects/electron-forge-react-vite-boilerplate/.vite/build/main-b0efc4c7.js:556:2343)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async lfA.launch (/Users/nolan/Work/JsProjects/electron-forge-react-vite-boilerplate/.vite/build/main-b0efc4c7.js:556:1465)
    at async /Users/nolan/Work/JsProjects/electron-forge-react-vite-boilerplate/.vite/build/main-b0efc4c7.js:660:99124
    at async WebContents.<anonymous> (node:electron/js2c/browser_init:2:89452)
@flaviodelgrosso
Copy link
Owner

@fanksy Hello, thanks for opening issue. I'll try to investigate about that.

@flaviodelgrosso
Copy link
Owner

In the meantime, I've upgraded the core dependencies and @electron/forge to the latest version. Can you try to update and check if the problem persists?

Can you also provide a reproducible case for this issue?
Thanks

@fanksy
Copy link
Author

fanksy commented Jun 9, 2024

I replaced puppeteer with playwright, it works well.

Thanks for your attention. I really appreciate for your work.

@fanksy fanksy closed this as completed Jun 9, 2024
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