Skip to content

Commit

Permalink
fix buffering
Browse files Browse the repository at this point in the history
  • Loading branch information
shuding committed Jul 12, 2022
1 parent b39eb38 commit 965376f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/next/client/app-index.tsx
Expand Up @@ -173,7 +173,7 @@ function useInitialServerResponse(cacheKey: string) {

const loadCssFromStreamData = (data: string) => {
if (data.startsWith('CSS:')) {
loadCss(data.slice(4))
loadCss(data.slice(4).trim())
}
}

Expand All @@ -195,6 +195,7 @@ function useInitialServerResponse(cacheKey: string) {
}
if (buffer && !buffer.startsWith('CSS:')) {
controller.enqueue(new TextEncoder().encode(buffer))
buffer = ''
}
},
flush() {
Expand Down
3 changes: 2 additions & 1 deletion packages/next/client/components/app-router.client.tsx
Expand Up @@ -33,7 +33,7 @@ async function loadCss(cssChunkInfoJson: string) {

const loadCssFromStreamData = (data: string) => {
if (data.startsWith('CSS:')) {
loadCss(data.slice(4))
loadCss(data.slice(4).trim())
}
}

Expand Down Expand Up @@ -64,6 +64,7 @@ function fetchFlight(url: URL, flightRouterStateData: string): ReadableStream {
}
if (buffer && !buffer.startsWith('CSS:')) {
controller.enqueue(new TextEncoder().encode(buffer))
buffer = ''
}
},
flush() {
Expand Down

0 comments on commit 965376f

Please sign in to comment.