-
-
Notifications
You must be signed in to change notification settings - Fork 282
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
Displayed error modals when connection to server fails #176
base: next
Are you sure you want to change the base?
Conversation
@Mounayer Thanks for taking this up and preparing such a nice PR description! I don't recall what the context of the original issue was (which is a miss from my side) but I think it was related to socket connections getting closed due to errors resulting in no UI feedback. WebSocket has 4 events:
The first 3 are already handled and errors sent by server leading to socket closure are handled through I like the other error cases you've handled, we can improve it even more:
|
Hi @blenderskool , I'm glad my PR description was good! I generally try to be as clear as possible in my pull requests, and provide as much context as I can! First, let me address your suggested changes: First Case: I completely agree! That's what I personally would have done myself, I just assumed the standard way to handle errors were through the modals, after seeing the error handler in the Second case: I also agree about this, I think showing an error message related to the specific cause of the error without disabling access to other things that might not be faulty is the right way to go. However, I'm not sure what you mean by Finally, I'll immediately get into displaying an error modal in the file sharing page when an error occurs, since there's no way to recover from this besides refreshing the page! Thank you for your detailed feedback! Edit: I have updated the QR code error to display in the same QR modal, instead of the I have also added an event listener that listens in on any I would just like more clarification regarding the Thanks again! Edit 2: Upon further inspection, while I did manage to find way to display "Local peers could not be loaded, please try again" in the peer room, It is being shadowed by the exiting error that appears if the connection is bad, i.e.: This is in the |
I think we can remove the error modal for local peers. I thought about showing it at the place where local peers are getting rendered, but I don't think it'll look good. We should be fine with not showing anything when an error occurs for local peers. |
Can we catch the errors from this line too?
|
I've removed the error modal for local peers, also great catch on the this.fileShare = socketConnect(this.client.isLocal ? '' : this.client.room, this.client.name);
const { socket } = this.fileShare; Then the error modal will be triggered below if there is an error in the connection, here: socket.on('error', err => {
this.setState({
errorModal: {
isOpen: true,
type: err.reason || constants.ERR_CONN_CLOSED,
},
});
}); This can be a beneficial message to the client, having a modal pop up which it already does, however... If the function socketConnect(room, username) {
const socket = new Socket(new WebSocket(urls.WS_HOST));
const fileShare = new FileShare(socket);
socket.name = username;
socket.on('open', () => {
socket.send(constants.JOIN, {
roomName: room,
name: username,
peerId: fileShare.isWebRTC ? fileShare.torrentClient.peerId : null,
});
});
return fileShare;
} the previously mentioned lines would not execute, because it'll hang here, no? I think for this very specific case, printing the error message to I can maybe wrap this line with a try catch? try{
// code before
this.fileShare = socketConnect(this.client.isLocal ? '' : this.client.room, this.client.name);
// rest of code
}
catch(err)
{
console.err(err);
} Let me know what you think is best, I'm open to suggestions! |
Description
Closes #172
Using the already existing modal component, I have covered two edge cases when an error happens, and nothing is displayed to the user.
First case
If the user goes to their room and clicks on the QR code button quickly, before the
Connection closed
modal pops up, they are presented with the modal that displays the QR code, with a broken image of the QR code, since there's no connection to the server. I simply added an onError listener to theimg
element, that now clearly displays an error modal with information to the user, i.e.:instead of just:
Second case
If the connection to the server is failing, we are unable to load the local peers, this failure is not being displayed to the user in any way. A simple modal is now being displayed when the peers are failing to load to the user, asking them to check their internet connection! i.e.:
Whereas before, while peers fail to load, no errors were being displayed at all.
Testing
Test by running the
client
without theserver
, go tolocalhost:8080/app
, you should have an error modal pop up telling you what the issue is.Test by running the
client
without theserver
, go tolocalhost:8080/app
, and try to go to thelocal network room
really quick before the error modal pops up, and continue to quickly click on theQR
button, that displays the modal which displays theQR
code. You should not get an error message when it fails to retrieve the properQR
code from the server.Please let me know if there are any suggestion or requested changes, I'd be glad to apply them!