()
| 105 | cancelled = false; |
| 106 | finished = false; |
| 107 | function makeSlowStream() { |
| 108 | // Web ReadableStream so .cancel() is callable; emits one chunk fast, |
| 109 | // then waits "forever" — exactly the shape an SSE upstream takes on a |
| 110 | // long Anthropic response. The cancel callback marks observable state |
| 111 | // so the test can assert it fired. |
| 112 | return new ReadableStream({ |
| 113 | start(controller) { |
| 114 | controller.enqueue(new TextEncoder().encode('data: {"type":"message_start"}\n\n')); |
| 115 | }, |
| 116 | cancel() { cancelled = true; }, |
| 117 | }); |
| 118 | } |
| 119 | const routes = { |
| 120 | 'POST /test/slow': async () => { |
| 121 | const stream = makeSlowStream(); |
no outgoing calls
no test coverage detected