Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ext/node): tls.connect regression #27707

Merged
merged 4 commits into from
Jan 17, 2025

Conversation

kt3k
Copy link
Member

@kt3k kt3k commented Jan 17, 2025

The TLS start sequence has been broken since #26661 because of the way how we wrap TCP handle to create TLS handle.

#26661 introduced happy-eyeballs algorithm and some connection could be dropped because of happy-eyeball attempt timeout. The current implementation doesn't consider that case and it could start TLS handshake with timed out TCP connection. That caused #27652 .

This PR fixes it by changing the initialization steps. Now wrapHandle of TLSSocket set up afterConnectTls callback in TCP handle, and afterConnect of TCP handle calls it at connect event timing if it exists. This avoids starting TLS session with timed out connection.

closes #27652

@kt3k kt3k added the ci-draft Run the CI on draft PRs. label Jan 17, 2025
@kt3k kt3k force-pushed the fix-tls-connect-regression branch from 6c94ccd to 6f228fc Compare January 17, 2025 07:05
@kt3k kt3k marked this pull request as ready for review January 17, 2025 11:13
Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM, nice catch

@kt3k kt3k merged commit b55451b into denoland:main Jan 17, 2025
33 checks passed
@kt3k kt3k deleted the fix-tls-connect-regression branch January 17, 2025 15:10
bartlomieju pushed a commit to bartlomieju/deno that referenced this pull request Jan 17, 2025
The TLS start sequence has been broken since denoland#26661 because of the way
how we wrap TCP handle to create TLS handle.

denoland#26661 introduced happy-eyeballs algorithm and some connection could be
dropped because of happy-eyeball attempt timeout. The current
implementation doesn't consider that case and it could start TLS
handshake with timed out TCP connection. That caused denoland#27652 .

This PR fixes it by changing the initialization steps. Now `wrapHandle`
of TLSSocket set up `afterConnectTls` callback in TCP handle, and
`afterConnect` of TCP handle calls it at `connect` event timing if it
exists. This avoids starting TLS session with timed out connection.

closes denoland#27652
crowlKats pushed a commit that referenced this pull request Jan 21, 2025
The TLS start sequence has been broken since #26661 because of the way
how we wrap TCP handle to create TLS handle.

#26661 introduced happy-eyeballs algorithm and some connection could be
dropped because of happy-eyeball attempt timeout. The current
implementation doesn't consider that case and it could start TLS
handshake with timed out TCP connection. That caused #27652 .

This PR fixes it by changing the initialization steps. Now `wrapHandle`
of TLSSocket set up `afterConnectTls` callback in TCP handle, and
`afterConnect` of TCP handle calls it at `connect` event timing if it
exists. This avoids starting TLS session with timed out connection.

closes #27652

(cherry picked from commit b55451b)
kt3k added a commit that referenced this pull request Jan 28, 2025
)

This PR resolves 2 issues of Socket class of node compat (both are
related to playwright)

Currently `browser.launch()` of playwright is not working.
`browser.launch` opens PipeTransport (which is based on Pipe/IPC socket)
with the browser process. But that pipe doesn't start reading the data
because of the workaround #27662 (which pauses the socket at the
beginning if it's from playwright-core). This PR fixes this issue by
checking whether the given handle is `ipc` handle or not.

Another issue is that sock-init-workaround for TLS connection stopped
working at #27707 because of the changes of TLS socket initialization
steps. This change fixes the issue by correctly returning the function
in workaround path.

The added case `specs::npm::playwright_compat` checks both fixes with
actual playwright and playwright-core packages.

`browser.launch` issues
closes #16899
closes #27623 

`https.request` issue
closes #27658
bartlomieju pushed a commit that referenced this pull request Jan 30, 2025
)

This PR resolves 2 issues of Socket class of node compat (both are
related to playwright)

Currently `browser.launch()` of playwright is not working.
`browser.launch` opens PipeTransport (which is based on Pipe/IPC socket)
with the browser process. But that pipe doesn't start reading the data
because of the workaround #27662 (which pauses the socket at the
beginning if it's from playwright-core). This PR fixes this issue by
checking whether the given handle is `ipc` handle or not.

Another issue is that sock-init-workaround for TLS connection stopped
working at #27707 because of the changes of TLS socket initialization
steps. This change fixes the issue by correctly returning the function
in workaround path.

The added case `specs::npm::playwright_compat` checks both fixes with
actual playwright and playwright-core packages.

`browser.launch` issues
closes #16899
closes #27623 

`https.request` issue
closes #27658
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-draft Run the CI on draft PRs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tls.connect from node:tls errors with ECONNRESET after sending data
3 participants