Fix a bug that cause UnhandledPromiseRejectionWarning on error #195
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.
#194
This PR tries to fix a bug that cause stray unhandled promises when runs on NodeJS app even if client.onerror is specified.
The cause is when IMAP close with an error, for example,
Socket closed unexpectedly!
, it will try clean _clientQueue and _currentCommand with the same error. However, _currentCommand's callback simply rejects the promise, but nowhere to catch the promise rejection or even find it without reading hundreds lines of the code. Problem code is here: client.js#L718Simply swallow the rejection is safe, as the original code simply throws it without giving the user any chance to catch it.
This PR breaks the test as the same error will not be rejected twice. I think this behavior should be ok.