| 305 | const errors = []; |
| 306 | const controller = new AbortController(); |
| 307 | function App() { |
| 308 | controller.abort(); |
| 309 | return ( |
| 310 | <Suspense fallback={<div>Loading</div>}> |
| 311 | <InfiniteSuspend /> |
| 312 | </Suspense> |
| 313 | ); |
| 314 | } |
| 315 | const streamPromise = ReactDOMFizzStatic.prerenderToNodeStream( |
| 316 | <div> |
| 317 | <App /> |
| 318 | </div>, |
| 319 | { |
| 320 | signal: controller.signal, |
| 321 | onError(x) { |
| 322 | errors.push(x.message); |
| 323 | }, |
| 324 | }, |
| 325 | ); |
| 326 | |
| 327 | if (gate(flags => flags.enableHalt)) { |
| 328 | const {prelude} = await streamPromise; |
| 329 | const content = await readContent(prelude); |
| 330 | expect(errors).toEqual(['This operation was aborted']); |
| 331 | expect(content).toBe(''); |
| 332 | } else { |
| 333 | let caughtError = null; |
| 334 | try { |
| 335 | await streamPromise; |
| 336 | } catch (error) { |
| 337 | caughtError = error; |
| 338 | } |
| 339 | expect(caughtError.message).toBe('This operation was aborted'); |
| 340 | expect(errors).toEqual(['This operation was aborted']); |
| 341 | } |
| 342 | }); |
| 343 | |
| 344 | // @gate enableHalt || enablePostpone |