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

Catch WebSocket JS exceptions in library_websocket.js #21713

Open
johnwason opened this issue Apr 7, 2024 · 0 comments
Open

Catch WebSocket JS exceptions in library_websocket.js #21713

johnwason opened this issue Apr 7, 2024 · 0 comments

Comments

@johnwason
Copy link
Contributor

Version of emscripten/emsdk:
Please include the output emcc -v here

I am using the latest Pyodide master version that appears to be using Emscripten version 3.1.52

I am receiving errors such as the following console message when using WebSockets:

pyodide.asm.js:9 Uncaught DOMException: Failed to execute 'close' on 'WebSocket': The close code must be either 1000, or between 3000 and 4999. 0 is neither.
    at _emscripten_websocket_close (http://localhost:8000/robotraconteur_pyodide/pyodide/pyodide.asm.js:9:519374)
    at wasm://wasm/04206a8e:wasm-function[8899]:0xaba21d
    at invoke_vi (http://localhost:8000/robotraconteur_pyodide/pyodide/pyodide.asm.js:9:1214419)
    at wasm://wasm/04206a8e:wasm-function[8893]:0xab775b
    at socket.onclose (http://localhost:8000/robotraconteur_pyodide/pyodide/pyodide.asm.js:9:516980)
WebSocket is already in CLOSING or CLOSED state.

And then a long WASM stack trace that I can't seem to copy out of the log for some reason.

It appears that the library_websocket.js functions are not catching JS exceptions generated by WebSocket functions, and are instead letting the JS exceptions pass back into WASM where they can't be caught. This is resulting in my entire application crashing. While my software clearly has some problems with how it is using WebSockets, if the error return was being handled correctly it would be able to recover. They JS exceptions should be caught, and an error code gracefully returned.

This is something I can work on in the next few weeks.

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

1 participant