Merge pull request #1 from sr2ds/fix/render-massive-pages-heap-out-of-memory

refactor: rendering pages as batch
pull/3285/head
David Silva 2 years ago committed by GitHub
commit 08df9c26c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -106,24 +106,30 @@ export async function build(
}
}
await Promise.all(
['404.md', ...siteConfig.pages]
.map((page) => siteConfig.rewrites.map[page] || page)
.map((page) =>
renderPage(
render,
siteConfig,
page,
clientResult,
appChunk,
cssChunk,
assets,
pageToHashMap,
metadataScript,
additionalHeadTags
const pages = ['404.md', ...siteConfig.pages]
const batchSize = 100
for (let i = 0; i < pages.length; i += batchSize) {
const batch = pages.slice(i, i + batchSize)
await Promise.all(
batch
.map((page) => siteConfig.rewrites.map[page] || page)
.map((page) =>
renderPage(
render,
siteConfig,
page,
clientResult,
appChunk,
cssChunk,
assets,
pageToHashMap,
metadataScript,
additionalHeadTags
)
)
)
)
)
}
})
// emit page hash map for the case where a user session is open

Loading…
Cancel
Save