@@ -263,33 +263,7 @@ jsg::Ref<Socket> connectImpl(
263
263
return connectImplNoOutputLock (js, kj::mv (fetcher), kj::mv (address), kj::mv (options));
264
264
}
265
265
266
- // Closes the underlying socket connection. This is an old implementation and will be removed soon.
267
- // See closeImplNew below for the new implementation.
268
- //
269
- // TODO(later): remove once safe
270
- jsg::Promise<void > Socket::closeImplOld (jsg::Lock& js) {
271
- // Forcibly close the readable/writable streams.
272
- auto cancelPromise = readable->getController ().cancel (js, kj::none);
273
- auto abortPromise = writable->getController ().abort (js, kj::none);
274
- // The below is effectively `Promise.all(cancelPromise, abortPromise)`
275
- return cancelPromise.then (js, [abortPromise = kj::mv (abortPromise), this ](jsg::Lock& js) mutable {
276
- return abortPromise.then (js, [this ](jsg::Lock& js) {
277
- resolveFulfiller (js, kj::none);
278
- return js.resolvedPromise ();
279
- }, [this ](jsg::Lock& js, jsg::Value err) {
280
- errorHandler (js, kj::mv (err));
281
- return js.resolvedPromise ();
282
- });
283
- }, [this ](jsg::Lock& js, jsg::Value err) {
284
- errorHandler (js, kj::mv (err));
285
- return js.resolvedPromise ();
286
- });
287
- }
288
-
289
- // Closes the underlying socket connection, but only after the socket connection is properly
290
- // established through any configured proxy. This method also flushes the writable stream prior to
291
- // closing.
292
- jsg::Promise<void > Socket::closeImplNew (jsg::Lock& js) {
266
+ jsg::Promise<void > Socket::close (jsg::Lock& js) {
293
267
if (isClosing) {
294
268
return closedPromiseCopy.whenResolved (js);
295
269
}
@@ -322,14 +296,6 @@ jsg::Promise<void> Socket::closeImplNew(jsg::Lock& js) {
322
296
});
323
297
}
324
298
325
- jsg::Promise<void > Socket::close (jsg::Lock& js) {
326
- if (util::Autogate::isEnabled (util::AutogateKey::SOCKETS_AWAIT_PROXY_BEFORE_CLOSE)) {
327
- return closeImplNew (js);
328
- } else {
329
- return closeImplOld (js);
330
- }
331
- }
332
-
333
299
jsg::Ref<Socket> Socket::startTls (jsg::Lock& js, jsg::Optional<TlsOptions> tlsOptions) {
334
300
JSG_REQUIRE (!isSecureSocket, TypeError, " Cannot startTls on a TLS socket." );
335
301
// TODO: Track closed state of socket properly and assert that it hasn't been closed here.
0 commit comments