mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 12:20:20 +01:00
[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:
parent
4448b18760
commit
c250b7d980
|
|
@ -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(() => {
|
||||
|
|
|
|||
2
packages/react-server/src/ReactFizzServer.js
vendored
2
packages/react-server/src/ReactFizzServer.js
vendored
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user