Some components in v5.x produces a lot of HTML due to inlined-css
See original GitHub issueReproduction link
https://github.com/Fiaxhs/ant5-row-col-overflow
Steps to reproduce
- Fork the NextJS with antd template ( https://github.com/vercel/next.js/tree/canary/examples/with-ant-design )
- Add a bunch of Row/Col element to a page
- Have that page export a
getServerSideProps
function, so it renders on the server ( see pages/index.tsx ) - Deploy to Vercel
Vercel crashes and outputs an HTTP 413 error code
[ERROR] [1668965449986] LAMBDA_RUNTIME Failed to post handler success response. Http response code: 413.
Note: this works fine on local, and probably on any other env where the hard limit for a rendered page is larger than 4.5MB
What is expected?
The page displays normally.
What is actually happening?
It looks like antd v5.x is much more verbose in HTML than v4.x: Here’s a working example with v4 https://github.com/Fiaxhs/ant4-row-col-overflow where pages/index.tsx has many more components and it still manage to work.
My guess is that rendering pages/index.tsx produces more than 4.5MB of HTML: https://vercel.com/docs/concepts/limits/overview#serverless-function-payload-size-limit
Here’s the same example using antd v4.x with almost the double of components and still works fine: https://github.com/Fiaxhs/ant4-row-col-overflow
Environment | Info |
---|---|
antd | 5.0.0 |
React | 18.2.0 |
System | Vercel |
Browser | Any |
I’ve had this error while migrating from 4.x to 5.x on less convoluted pages, with a reasonable amount of components being rendered. Took me a while to figure out that having a bunch of Row Col would generate too much HTML
Issue Analytics
- State:
- Created 10 months ago
- Comments:8 (6 by maintainers)
Top GitHub Comments
Ref https://ant.design/docs/react/customize-theme#server-side-render-ssr
Default ssr will render style inline which may increase size of style. Extract instead will reduce size.
@Fiaxhs This is caused by repeated generation of styles. One of the current solutions is to extract styles:
pages/_document.tsx: