Conversation
onConnectionError only fired ImapConnectionLostEvent, so a command that was awaiting a response when the socket died never completed: with no responseTimeout set, `await sendCommand(...)` hung for the lifetime of the process, and even with one it waited out the full timeout for an error that had already arrived. The event cannot complete the caller's future on its own. Every queued or in-flight CommandTask is now error-completed with an ImapException before the event is fired, mirroring what _failPendingIdleContinuation already does for idleStart.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ImapClient.onConnectionErrorreset state and firedImapConnectionLostEvent, but never completed the futures of commands that were queued or awaiting a response. With noresponseTimeoutset,await client.noop()(or any other command in flight when the socket died) hung for the lifetime of the process. With a timeout set it still waited out the full timeout for an error that had already arrived. The event cannot complete the caller's future on its own.Fix
Before firing the event, every
CommandTaskin_queueand_tasksis error-completed withImapException(this, 'connection lost: $error'), and the queue, task map, current task and idle task are cleared. This mirrors what_failPendingIdleContinuation(#274) already does foridleStart(waitForContinuation: true), extended to all commands.Tests
Two new tests in
imap_client_test.dart: one in-flight NOOP, and one in-flight NOOP with a second queued behind it. Both driveclient.onConnectionError(...)directly and expect anImapException. Without the fix both tests time out.