Skip to content

Commit 28becd8

Browse files
committed
Resolves remaining TODOs
1 parent 3e5c224 commit 28becd8

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

index.bs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,26 @@ The `closed` promise can be used to keep track of the socket state. It gets reso
119119
following circumstances:
120120

121121
* the `close` method is called on the socket
122-
* the socket was constructed with the `allowHalfOpen` parameter set to `false` and the remote
123-
connection sends a FIN packet
122+
* the socket was constructed with the `allowHalfOpen` parameter set to `false`, the ReadableStream
123+
is being read from, and the remote connection sends a FIN packet (graceful closure) or a RST
124+
packet
124125

125-
// TODO: What happens when connection gets reset by peer (i.e. RST packet without FIN)?
126-
// TODO: What happens when both readable and writable are closed?
126+
<div class="note">
127+
The current Cloudflare Workers implementation behaves as described above, specifically the
128+
ReadableStream needs to be read until completion for the `closed` promise to resolve, if the
129+
ReadableStream is not read then even if the server closes the connection the `closed` promise
130+
will not resolve.
131+
132+
Whether the promise should resolve without the ReadableStream being read is up for discussion.
133+
</div>
127134

128135
It can also be rejected with an exception under the following circumstances:
129136

130137
* a socket connection could not be established, either because the address/port combo requested is
131138
blocked or due to a transient issue with the runtime
132139

140+
Cancelling the socket's ReadableStream and closing the socket's WritableStream does not resolve the
141+
`closed` promise.
133142

134143
`startTls` method {#starttls-method}
135144
------------------------------------

0 commit comments

Comments
 (0)