Skip to content

[Flight] Close Debug Channel when All Lazy References Have Been GC:ed #33718

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 7, 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
55 changes: 43 additions & 12 deletions fixtures/flight/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,49 @@ function findSourceMapURL(fileName) {

let updateRoot;
async function callServer(id, args) {
const response = fetch('/', {
method: 'POST',
headers: {
Accept: 'text/x-component',
'rsc-action': id,
},
body: await encodeReply(args),
});
const {returnValue, root} = await createFromFetch(response, {
callServer,
findSourceMapURL,
});
let response;
if (
process.env.NODE_ENV === 'development' &&
typeof WebSocketStream === 'function'
) {
const requestId = crypto.randomUUID();
const wss = new WebSocketStream(
'ws://localhost:3001/debug-channel?' + requestId
);
const debugChannel = await wss.opened;
response = createFromFetch(
fetch('/', {
method: 'POST',
headers: {
Accept: 'text/x-component',
'rsc-action': id,
'rsc-request-id': requestId,
},
body: await encodeReply(args),
}),
{
callServer,
debugChannel,
findSourceMapURL,
}
);
} else {
response = createFromFetch(
fetch('/', {
method: 'POST',
headers: {
Accept: 'text/x-component',
'rsc-action': id,
},
body: await encodeReply(args),
}),
{
callServer,
findSourceMapURL,
}
);
}
const {returnValue, root} = await response;
// Refresh the tree with the new RSC payload.
startTransition(() => {
updateRoot(root);
Expand Down
Loading
Loading