| 868 | } { |
| 869 | let subscriber: ReadableStreamDefaultController<ExecEvent> | undefined; |
| 870 | const subscribe = (id: string): ReadableStream<ExecEvent> => { |
| 871 | if (subscriber !== undefined) { |
| 872 | throw new Error(`EEXEC_BUSY: exec ${id} already has a live subscriber`); |
| 873 | } |
| 874 | return new ReadableStream<ExecEvent>({ |
| 875 | start(c) { |
| 876 | subscriber = c; |
| 877 | }, |
| 878 | cancel() { |
| 879 | subscriber = undefined; |
| 880 | }, |
| 881 | }); |
| 882 | }; |
| 883 | return { |
| 884 | // The runner closes the subscriber's stream after the exit |
| 885 | // event; result() drains until close. |