Skip to content

Commit e4aeea7

Browse files
xueayicursoragent
andauthored
fix: await async generateRss/checkDataFromAlgolia in getStaticProps (notionnext-org#3992)
`generateRss` and `checkDataFromAlgolia` are both async functions, but they were called without `await` inside `getStaticProps`. This creates a race condition where the build process may finish and proceed to deployment before the RSS files (public/rss/feed.xml, atom.xml, feed.json) are actually written to disk. Contrast with `generateRobotsTxt` and `generateSitemapXml` which are synchronous and complete immediately — they are unaffected. Symptoms: - RSS feed returns 404 or corrupted content after deployment - The issue is non-deterministic (depends on how many posts need Notion API calls and whether the build finishes first) - More likely to manifest in CI/CD environments where the build completes quickly and immediately copies artifacts Root cause in generateRss: - For each post, it calls `await getPostBlocks(post.id, 'rss-content')` to fetch content from the Notion API - Then renders each post via `ReactDOMServer.renderToString()` - Finally writes feed.xml / atom.xml / feed.json to public/rss/ - Without `await`, getStaticProps returns before any of this completes The fix simply adds `await` to both calls so getStaticProps waits for file generation to complete before returning. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent e1f0792 commit e4aeea7

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

pages/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ export async function getStaticProps(req) {
9191
// 生成robotTxt
9292
generateRobotsTxt(props)
9393
// 生成Feed订阅
94-
generateRss(props)
94+
await generateRss(props)
9595
// 生成
9696
generateSitemapXml(props)
9797
// 检查数据是否需要从algolia删除
98-
checkDataFromAlgolia(props)
98+
await checkDataFromAlgolia(props)
9999
if (siteConfig('UUID_REDIRECT', false, props?.NOTION_CONFIG)) {
100100
// 生成重定向 JSON
101101
generateRedirectJson(props)

0 commit comments

Comments
 (0)