Repository navigation
Reject openConnection when CAPABILITY fails after greeting - #30
Merged
Merged
Conversation
If the server sends a greeting and then closes the socket while the
initial CAPABILITY command is pending, the updateCapability() promise
rejected with no handler, surfacing as an unhandledRejection
("Socket closed unexpectedly!", command=CAPABILITY) that crashes
pmailer-syncer-imap.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
|
/review |
Author
will not work in public repo |
SergeyShuvalov
approved these changes
Sep 29, 2026
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.
Description
When an IMAP server sends its greeting and then closes the socket while the initial
CAPABILITYcommand is pending,openConnection()left theupdateCapability()promise without a rejection handler. The rejection (Socket closed unexpectedly!,command: "CAPABILITY") escaped as anunhandledRejection, which crashes consumers that treat unhandled rejections as fatal.Fix:
.catch(reject)onupdateCapability()inopenConnection(), soconnect()rejects normally and callers can handle it.dist/client.jsis patched by hand for that one line. A fullnpm run buildwith the current toolchain rewrites all ofdist/with unrelated Babel helper changes.What type of PR is this?
Manual testing
Ran a local TCP server that sends
* OK helloand closes the socket on receivingCAPABILITY, then calledclient.connect()againstdist/client.js:connect()rejects and anUNHANDLED REJECTION: Socket closed unexpectedly! command=CAPABILITYis emittedconnect()rejects cleanly, no unhandled rejectionAdded automated tests?
The new test in
#openConnectionfails on master withUncaught Error: Socket closed unexpectedly!and passes with the fix (70/70 unit tests).Updated documentation?
🤖 Generated with Claude Code