-
Notifications
You must be signed in to change notification settings - Fork 6
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
expose clientHasQuit error #99
Conversation
I'm open to this, but internally to the library we are just checking whether |
Interesting! Thanks for pointing this out. I honestly haven't really gotten very deep into understanding how things are actually wired up. To me, it feels less brittle to just explicitly check the error instead of inferring what it must be based on this other state. I think that personally I would prefer even the current string based check. I'm mostly just trying to make this drive-by one line logging change though. Happy to do it however @zze0s prefers. |
Like pointed out we do keep track of manuallyDisconnected so we can use that, but exported errors are pretty nice so we can easily use I don't have any strong opinions on this, but exported errors are useful. |
I'm open to merging this, but the more I look at this code, the more I think it's unlikely to solve your problems. The only site where this error can be returned is: Lines 615 to 617 in 8d1f09a
This is intended to cover a specific case (client code asynchronously called Line 304 in 8d1f09a
If you're calling |
I did see it, though not consistently. I was toggling the state of a network, trying to get errors. My hypothesis would be that
|
Thanks, that explanation makes sense (it's similar to the "Quit() in between reconnection attempts" scenario described above that occurs internally within the library, and which is solved by returning Reading the autobrr code, I think there are probably a number of race conditions associated with toggling networks on and off (for example, you can probably end up with two different |
I replied to this on the downstream PR here: The part that's relevant to this PR is my suggestion that we
I agree that we can sidestep being able to check the value of this error in this case, but I think as a general principle it's nice to export errors which we plan to return to clients to help the client handle errors more easily. |
I think in principle, exported errors should correspond to expected conditions that the caller might want to check and respond to with specific behaviors. Given that That said, there's no very compelling reason not to merge this (it doesn't really affect API stability to have an extra exported error, even one that eventually becomes obsolete), so I'll just merge this. I'm not going to prioritize including it in a tagged release, though. |
That seems like a good balance. Thanks for merging :) |
In autobrr/autobrr#1239 we would like to check if the error returned is a
clientHasQuit
error and handle it differently if so.