Skip to content

Commit 71d3a00

Browse files
don't send first chunk until shell is rendered
1 parent 122e85a commit 71d3a00

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

node_package/src/injectRSCPayload.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@ export default function injectRSCPayload(
103103
};
104104

105105
const writeHTMLChunks = () => {
106+
if (htmlBuffer.length === 0) {
107+
return;
108+
}
109+
110+
if (!rscPromise) {
111+
rscPromise = startRSC();
112+
}
113+
106114
resultStream.push(Buffer.concat(htmlBuffer));
107115
htmlBuffer.length = 0;
108116
};
@@ -114,9 +122,6 @@ export default function injectRSCPayload(
114122
}
115123

116124
timeout = setTimeout(() => {
117-
if (!rscPromise) {
118-
rscPromise = startRSC();
119-
}
120125
writeHTMLChunks();
121126
timeout = null;
122127
}, 0);
@@ -130,10 +135,13 @@ export default function injectRSCPayload(
130135
if (timeout) {
131136
clearTimeout(timeout);
132137
}
138+
writeHTMLChunks();
139+
133140
if (!rscPromise) {
134-
rscPromise = startRSC();
141+
resultStream.end();
142+
return;
135143
}
136-
writeHTMLChunks();
144+
137145
rscPromise
138146
.then(() => {
139147
resultStream.end();

0 commit comments

Comments
 (0)