psanford / wormhole-william

End-to-end encrypted file transfer. A magic wormhole CLI and API in Go (golang).
MIT License
1.08k stars 55 forks source link

More graceful errors when cancelled #53

Open Jacalz opened 3 years ago

Jacalz commented 3 years ago

As of https://github.com/psanford/wormhole-william/commit/049df45b8d5a40e6f5f3f43ea7d8c423631ed7ed, cancelling incomming and outgoing connections works great. However, it would be nice if the errors could be a bit more graceful. This does not affect the latest stable release yet.

Cancelling the outgoing send returns this (first error being in the sending end and the second in the receiving end):

2021/05/20 21:01:28 Fyne error:  Error on sending file
2021/05/20 21:01:28   Cause: write tcp 192.168.1.220:43901->192.168.1.220:36580: use of closed network connection
2021/05/20 21:01:28   At: /home/jacob/go/src/github.com/Jacalz/wormhole-gui/internal/transport/bridge/send.go:112
2021/05/20 21:01:28 Fyne error:  Error on copying contents to file
2021/05/20 21:01:28   Cause: unexpected EOF
2021/05/20 21:01:28   At: /home/jacob/go/src/github.com/Jacalz/wormhole-gui/internal/transport/receiver.go:71

Cancelling the incoming receive returns this. Here, the first error (from the receiving end) is what I would like to see, but the second error is not quite as graceful.

2021/05/20 21:02:02 Fyne error:  Error on copying contents to file
2021/05/20 21:02:02   Cause: context canceled
2021/05/20 21:02:02   At: /home/jacob/go/src/github.com/Jacalz/wormhole-gui/internal/transport/receiver.go:71
2021/05/20 21:02:02 Fyne error:  Error on sending file
2021/05/20 21:02:02   Cause: write tcp 192.168.1.220:43167->192.168.1.220:55670: write: connection reset by peer
2021/05/20 21:02:02   At: /home/jacob/go/src/github.com/Jacalz/wormhole-gui/internal/transport/bridge/send.go:112

I would like it if all the errors could fail gracefully with "context cancelled".

Jacalz commented 3 years ago

It would also be great if the "context canceled" error could be exposed somewhere (I could not find where it is created). This would allow me to check if it was cancelled and then avoid showing a bunch of error messages to the users in wormhole-gui.

bryanchriswhite commented 3 years ago

It would also be great if the "context canceled" error could be exposed somewhere (I could not find where it is created). This would allow me to check if it was cancelled and then avoid showing a bunch of error messages to the users in wormhole-gui.

Is context.Canceled not what you're looking for?

Jacalz commented 3 years ago

It would also be great if the "context canceled" error could be exposed somewhere (I could not find where it is created). This would allow me to check if it was cancelled and then avoid showing a bunch of error messages to the users in wormhole-gui.

Is context.Canceled not what you're looking for?

Ah, silly me. Don’t know how I didn’t find that when I was looking at that package. Thanks :)