Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix Socket's WorkerInterface Lifetime #466

Merged
merged 1 commit into from
Mar 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/workerd/api/sockets.c++
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "sockets.h"
#include "system-streams.h"
#include <workerd/io/worker-interface.h>


namespace workerd::api {
Expand Down Expand Up @@ -64,12 +65,13 @@ jsg::Ref<Socket> connectImplNoOutputLock(

// Set up the connection.
auto headers = kj::heap<kj::HttpHeaders>(ioContext.getHeaderTable());
auto httpClient = kj::newHttpClient(*client);
auto httpClient = asHttpClient(kj::mv(client));
kj::HttpConnectSettings httpConnectSettings = { .useTls = false };
KJ_IF_MAYBE(opts, options) {
httpConnectSettings.useTls = opts->useSecureTransport;
}
auto request = httpClient->connect(addressStr, *headers, httpConnectSettings);
request.connection = request.connection.attach(kj::mv(httpClient));
auto connDisconnPromise = request.connection->whenWriteDisconnected();

// Initialise the readable/writable streams with the readable/writable sides of an AsyncIoStream.
Expand Down