Skip to content

fix(microservices): wait for the TCP TLS handshake - #18002

Merged
kamilmysliwiec merged 2 commits into
nestjs:masterfrom
jackie-cqz:fix/tcp-tls-handshake
Oct 8, 2026
Merged

kamilmysliwiec merged 2 commits into
nestjs:masterfrom
jackie-cqz:fix/tcp-tls-handshake

Conversation

@jackie-cqz

Copy link
Copy Markdown
Contributor

PR Checklist

  • Commit message follows the contribution guidelines
  • Regression tests added
  • Docs updated (no API additions)

PR Type

  • Bugfix

What is the current behavior?

The TLS ClientTCP uses the underlying TCP connect event as success. connect() resolves and reports connected before the TLS handshake finishes, including connections that subsequently fail certificate validation.

Issue Number: N/A

What is the new behavior?

Use secureConnect for TLS connection readiness and status reporting; plain TCP keeps its connect event. Six new tests cover event ordering, reply-listener binding, handshake errors, unchanged plain TCP behavior, and real stalled/successful/untrusted TLS connections.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Validation on this independent branch, based on master 35142c3eca8edaaf6abc5984d915da2fbd458aa2:

  • TCP client tests: 47 passed. TCP/TLS RPC integration tests: 22 passed.
  • Unit suite: 3818 passed. Two existing process-signal tests were excluded on Windows because they terminate the test worker: shutdown process should not be interrupted by another handler and should defer shutdown until all init hooks are resolved.
  • npm run build and npm run lint:ci passed.

Unit command:

npm test -- --reporter dot --testNamePattern '^(?!.*(shutdown process should not be interrupted by another handler|should defer shutdown until all init hooks are resolved)).*'

@kamilmysliwiec
kamilmysliwiec merged commit 12e3ffd into nestjs:master Oct 8, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants