-
Notifications
You must be signed in to change notification settings - Fork 39
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
Cancel outstanding requests when destroying conns #355
Conversation
tests-e2e/handler_test.go
Outdated
if response.duration > cancelWithin { | ||
t.Errorf("Waited for %s, but expected second sync to cancel after at most %s", response.duration, cancelWithin) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was my attempt to detect if the request was cancelled early.
I did wonder about explicitly making a request with client-created context. But I wasn't sure if http.Client would mark the context as Done when the request ends.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I wasn't sure if http.Client would mark the context as Done when the request ends.
seemingly not. That makes the test much cleaner.
sync3/handler/connstate.go
Outdated
@@ -723,6 +724,8 @@ func (s *ConnState) trackProcessDuration(ctx context.Context, dur time.Duration, | |||
// Called when the connection is torn down | |||
func (s *ConnState) Destroy() { | |||
s.userCache.Unsubscribe(s.userCacheID) | |||
logger.Debug().Str("user_id", s.userID).Str("device_id", s.deviceID).Msg("cancelling any in-flight requests") | |||
s.cancelLatestReq() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nil check?
Grr. Is there no tooling for this?
Will help with #294.