I am making a ws connection, but some cases want to abort the request, without the console logging an error –
WebSocket connection to ‘ws://xyz:3001/? failed: WebSocket is closed
before the connection is established.
the code looks like:
const ws = new WebSocket(`${xyz}`);
setTimeout(() => ws.close(), random); // some other event that occur at any given time "random"
A simple use case is if a connection is initiated when a user opens a view, but then quickly closes the view which could/should abort the connection request.
is there a way to abort the connection request cleanly, so that I don’t get too many logs like that in the browser console?