Skip to content
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

fix: duplicate app server #36710

Merged
merged 4 commits into from May 5, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 1 addition & 6 deletions packages/next/server/render.tsx
Expand Up @@ -208,13 +208,8 @@ function renderPageTree(
isServerComponent: boolean
) {
const { router: _, ...rest } = props

if (isServerComponent) {
return (
<App>
<Component {...rest} />
</App>
)
return <Component {...rest} />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep App here but remove it from ServerComponentWrapper, _app shouldn't be rendered as a part of server components. What's your take?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have to keep it inside ServerComponentWrapper for now since AppServer needs to be sent through streaming response as well

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since AppServer needs to be sent through streaming response as well

The definition of _app.server is blurry. If it is a client component, it shouldn't be included in the flight response. If it's a server component, it should be allowed to exist at the same time along with _app.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_app is the client one, which is not included in flight response yet. and you can have _app.server and _app at the same time.

}

return <App Component={Component} {...props} />
Expand Down
@@ -0,0 +1,7 @@
export default function App({ Component, pageProps }) {
return (
<div className="app-client-root">
<Component {...pageProps} />
</div>
)
}
Expand Up @@ -38,11 +38,12 @@ async function testRoute(appPort, url, { isStatic, isEdge, isRSC }) {
// Should be re-rendered.
expect(renderedAt1).toBeLessThan(renderedAt2)
}
const customAppServerHtml = '<div class="app-server-root"'
if (isRSC) {
expect(html1).toContain(customAppServerHtml)
const appServerOccurrence = html1.match(/class="app-server-root"/g) || []
expect(appServerOccurrence.length).toBe(1)
expect(html1).not.toContain('"app-client-root"')
} else {
expect(html1).not.toContain(customAppServerHtml)
expect(html1).not.toContain('"app-server-root"')
huozhi marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down