Skip to content

Always clear read idle timeout at the end of a request#455

Merged
dnadoba merged 3 commits into
swift-server:mainfrom
dnadoba:dn-read-idle-timeout-bug-fix
Oct 8, 2021
Merged

Always clear read idle timeout at the end of a request#455
dnadoba merged 3 commits into
swift-server:mainfrom
dnadoba:dn-read-idle-timeout-bug-fix

Conversation

@dnadoba

@dnadoba dnadoba commented Oct 8, 2021

Copy link
Copy Markdown
Collaborator

Motivation

As described in #453, we only clear the read idle timeout after we receive a http .end event. But if we e.g. cancel we did not clear the timeout and hit some precondition down the road. The same issues exists for HTTP/2 too.

Changes

  • clear the idle timeout always at the end of a request
  • remove the now redundant .clearIdleReadTimeoutTimer action that we previously returned after we have received a http .end
  • add tests which previously hit the precondition

@dnadoba

dnadoba commented Oct 8, 2021

Copy link
Copy Markdown
Collaborator Author

Nightly fails because of sendable requirements.

@Lukasa Lukasa added the 🔨 semver/patch No public API change. label Oct 8, 2021
enum Action {
case startIdleReadTimeoutTimer(TimeAmount)
case resetIdleReadTimeoutTimer(TimeAmount)
case clearIdleReadTimeoutTimer

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, if we should remove this from the state machine tbh. The more I think about it the more I think we should just create another event (requestFailed) or something that removes the timer in the error case. Just calling clearTimer into the air and not syncing with state machine probably leads to out of sync errors in the future.

if let newRequest = self.request, let idleReadTimeout = newRequest.requestOptions.idleReadTimeout {
self.idleReadTimeoutStateMachine = .init(timeAmount: idleReadTimeout)
} else {
self.clearIdleReadTimeoutTimer()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we should not trigger this here (though recommended by me earlier), but instead trigger a idle state machine event at all places where we cancel/fail the request.

@Lukasa Lukasa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants