You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When actix detects client disconnect (TCP write fails), it drops the ResponseBody receiver. The spawned task detects this via `tx.closed()` and calls`stream_manager.close_stream()`.
175
+
When Hyper detects client disconnect (TCP write fails), `StreamBody` is dropped. The `Drop` implementation sends a notification via a oneshot channel, which triggers`stream_manager.close_stream()`.
176
176
177
177
### exec() Loop Detection
178
178
@@ -212,29 +212,29 @@ enqueue(chunk) {
212
212
}
213
213
```
214
214
215
-
### __streamResponseBody Detection
215
+
### \_\_streamResponseBody Detection
216
216
217
217
For fetch forward and processed responses:
218
218
219
219
```javascript
220
220
// In worker.rs __streamResponseBody
221
221
while (true) {
222
-
const { value, done } = await reader.read();
223
-
if (done) break;
222
+
const { value, done } = await reader.read();
223
+
if (done) break;
224
224
225
-
while (!__responseStreamWrite(streamId, chunk)) {
226
-
if (__responseStreamIsClosed(streamId)) {
227
-
cancelled = true;
228
-
break; // Stop forwarding
229
-
}
230
-
await new Promise(r => setTimeout(r, 1));
225
+
while (!__responseStreamWrite(streamId, chunk)) {
226
+
if (__responseStreamIsClosed(streamId)) {
227
+
cancelled = true;
228
+
break; // Stop forwarding
231
229
}
230
+
await new Promise((r) => setTimeout(r, 1));
231
+
}
232
232
233
-
if (cancelled) break;
233
+
if (cancelled) break;
234
234
}
235
235
236
236
if (cancelled) {
237
-
await reader.cancel('Clientdisconnected');
237
+
await reader.cancel('Clientdisconnected');
238
238
}
239
239
```
240
240
@@ -325,7 +325,7 @@ async start(controller) {
325
325
There is an inherent delay (typically 1-5 seconds) between when a client disconnects and when the worker detects it. This is due to:
326
326
327
327
1. **TCP buffering** - Data is buffered at the OS level before being sent
328
-
2. **HTTP chunked encoding** - Actix buffers chunks before writing to the socket
328
+
2. **HTTP chunked encoding** - Hyper buffers chunks before writing to the socket
329
329
3. **Write-based detection** - Disconnect is only detected when a write fails
330
330
331
331
This is a fundamental limitation of HTTP streaming over TCP, not specific to OpenWorkers. The worker will eventually detect the disconnect and can then clean up.
0 commit comments