File tree Expand file tree Collapse file tree 4 files changed +20
-0
lines changed Expand file tree Collapse file tree 4 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @cloudflare/sandbox " : patch
3+ ---
4+
5+ close stream before releasing lock
Original file line number Diff line number Diff line change @@ -267,6 +267,12 @@ export class InterpreterClient extends BaseHttpClient {
267267 yield buffer ;
268268 }
269269 } finally {
270+ // Cancel the stream first to properly terminate HTTP connections when breaking early
271+ try {
272+ await reader . cancel ( ) ;
273+ } catch {
274+ // Ignore cancel errors (stream may already be closed)
275+ }
270276 reader . releaseLock ( ) ;
271277 }
272278 }
Original file line number Diff line number Diff line change @@ -37,6 +37,12 @@ async function* parseSSE(
3737 }
3838 }
3939 } finally {
40+ // Cancel the stream first to properly terminate HTTP connections when breaking early
41+ try {
42+ await reader . cancel ( ) ;
43+ } catch {
44+ // Ignore cancel errors (stream may already be closed)
45+ }
4046 reader . releaseLock ( ) ;
4147 }
4248}
Original file line number Diff line number Diff line change @@ -72,6 +72,9 @@ export async function* parseSSEStream<T>(
7272 }
7373 } finally {
7474 // Clean up resources
75+ try {
76+ await reader . cancel ( ) ;
77+ } catch { }
7578 reader . releaseLock ( ) ;
7679 }
7780}
You can’t perform that action at this time.
0 commit comments