| 263 | const errors = []; |
| 264 | const controller = new AbortController(); |
| 265 | function App() { |
| 266 | controller.abort(); |
| 267 | return ( |
| 268 | <Suspense fallback={<div>Loading</div>}> |
| 269 | <InfiniteSuspend /> |
| 270 | </Suspense> |
| 271 | ); |
| 272 | } |
| 273 | const streamPromise = serverAct(() => |
| 274 | ReactDOMFizzServer.renderToReadableStream( |
| 275 | <div> |
| 276 | <App /> |
| 277 | </div>, |
| 278 | { |
| 279 | signal: controller.signal, |
| 280 | onError(x) { |
| 281 | errors.push(x.message); |
| 282 | }, |
| 283 | }, |
| 284 | ), |
| 285 | ); |
| 286 | |
| 287 | let caughtError = null; |
| 288 | try { |
| 289 | await streamPromise; |
| 290 | } catch (error) { |
| 291 | caughtError = error; |
| 292 | } |
| 293 | expect(caughtError.message).toBe('The operation was aborted.'); |
| 294 | expect(errors).toEqual(['The operation was aborted.']); |
| 295 | }); |
| 296 | |
| 297 | it('should reject if passing an already aborted signal', async () => { |
| 298 | const errors = []; |