Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(websocket-websys): change close code in drop implementation to 1000
In browsers, only the code 1000 and codes between 3000-4999 are allowed to be set by userland code: https://websockets.spec.whatwg.org/#dom-websocket-close I found this while debugging use-after-free errors in our WASM application. Turns out, when connections are timing out, libp2p in rust drops them, but does not seem to close them explicitly (we are using libp2p-swarm). This led to these WebSockets still emitting events, the handlers of which were already dropped on the rust side, though. A long investigation led me to have a look into the `Result` that gets returned from `close_with_code_and_reason`, and it turns out it's an error! Specifically: ``` InvalidAccessError: Failed to execute 'close' on 'WebSocket': The code must be either 1000, or between 3000 and 4999. 1001 is neither. ``` This PR only fixes the failing closing of the WebSocket, not the remaining use-after-free problem. Pull-Request: #5229.
- Loading branch information