Skip to content

[pull] main from facebook:main #193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -863,4 +863,46 @@ describe('ReactFlightDOMNode', () => {
expect(ownerStack).toBeNull();
}
});

// @gate experimental
// @gate enableHalt
it('can handle an empty prelude when prerendering', async () => {
function App() {
return null;
}

const serverAbortController = new AbortController();
serverAbortController.abort();
const errors = [];
const {pendingResult} = await serverAct(async () => {
// destructure trick to avoid the act scope from awaiting the returned value
return {
pendingResult: ReactServerDOMStaticServer.unstable_prerender(
ReactServer.createElement(App, null),
webpackMap,
{
signal: serverAbortController.signal,
onError(error) {
errors.push(error);
},
},
),
};
});

expect(errors).toEqual([]);

const {prelude} = await pendingResult;

const reader = prelude.getReader();
while (true) {
const {done} = await reader.read();
if (done) {
break;
}
}

// We don't really have an assertion other than to make sure
// the stream doesn't hang.
});
});
3 changes: 2 additions & 1 deletion packages/react-server/src/ReactFlightServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5762,6 +5762,7 @@ function flushCompletedChunks(request: Request): void {
// TODO: If this destination is not currently flowing we'll not close it when it resumes flowing.
// We should keep a separate status for this.
if (request.destination !== null) {
request.status = CLOSED;
close(request.destination);
request.destination = null;
}
Expand All @@ -5779,8 +5780,8 @@ function flushCompletedChunks(request: Request): void {
);
request.cacheController.abort(abortReason);
}
request.status = CLOSED;
if (request.destination !== null) {
request.status = CLOSED;
close(request.destination);
request.destination = null;
}
Expand Down
Loading