[Fizz] Should be considered complete inside onShellReady callback (#33295)

We decremented `allPendingTasks` after invoking `onShellReady`. Which
means that in that scope it wasn't considered fully complete.

Since the pattern for flushing in Node.js is to start piping in
`onShellReady` and that's how you can get sync behavior, this led us to
think that we had more work left to do. For example we emitted the
`writeShellTimeInstruction` in this scenario before.
This commit is contained in:
Sebastian Markbåge 2025-05-16 14:53:40 -04:00 committed by GitHub
parent 4448b18760
commit c250b7d980
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 1 deletions

View File

@ -67,6 +67,21 @@ describe('ReactDOMFizzServerNode', () => {
expect(output.result).toMatchInlineSnapshot(`"<div>hello world</div>"`);
});
it('flush fully if piping in on onShellReady', async () => {
const {writable, output} = getTestWritable();
await act(() => {
const {pipe} = ReactDOMFizzServer.renderToPipeableStream(
<div>hello world</div>,
{
onShellReady() {
pipe(writable);
},
},
);
});
expect(output.result).toMatchInlineSnapshot(`"<div>hello world</div>"`);
});
it('should emit DOCTYPE at the root of the document', async () => {
const {writable, output} = getTestWritable();
await act(() => {

View File

@ -4335,6 +4335,7 @@ function finishedTask(
boundary: Root | SuspenseBoundary,
segment: null | Segment,
) {
request.allPendingTasks--;
if (boundary === null) {
if (segment !== null && segment.parentFlushed) {
if (request.completedRootSegment !== null) {
@ -4417,7 +4418,6 @@ function finishedTask(
}
}
request.allPendingTasks--;
if (request.allPendingTasks === 0) {
completeAll(request);
}