File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -119,17 +119,26 @@ The `closed` promise can be used to keep track of the socket state. It gets reso
119
119
following circumstances:
120
120
121
121
* 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
124
125
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>
127
134
128
135
It can also be rejected with an exception under the following circumstances:
129
136
130
137
* a socket connection could not be established, either because the address/port combo requested is
131
138
blocked or due to a transient issue with the runtime
132
139
140
+ Cancelling the socket's ReadableStream and closing the socket's WritableStream does not resolve the
141
+ `closed` promise.
133
142
134
143
`startTls` method {#starttls-method}
135
144
------------------------------------
You can’t perform that action at this time.
0 commit comments