Skip to content

v2: Sitemaps are not always generated #2516

@SamChou19815

Description

@SamChou19815

🐛 Bug Report

sitemap.xml is not always generated. It might be caused by #2443 and #2496 does not fix the issue for sitemap generation.

Here is the code that writes the sitemap file.

const sitemapPath = path.join(outDir, 'sitemap.xml');
fs.writeFile(sitemapPath, generatedSitemap, err => {
if (err) {
throw new Error(`Sitemap error: ${err}`);
}
});

Writing the file is async, and the process might already be killed before it was able to write the file. To confirm my hypothesis, I changed writeFile to writeFileSync and the problem seems to go away with my blog repo.

Have you read the Contributing Guidelines on issues?

Yes.

To Reproduce

The bug is not reproducible on every repo. I cannot reproduce it on the docusaurus v2 project, but I managed to reliably reproduce it for my blog repo (at least on my machine).

  1. Clone https://github.com/SamChou19815/website
  2. yarn
  3. yarn workspace blog build
  4. Observe packages/blog/build/sitemap.xml The file is empty.

Expected behavior

sitemap.xml is reliably generated.

Actual Behavior

sitemap.xml is not reliably generated.

Your Environment

  • Docusaurus version used: v2-alpha.50
  • Environment name and version (e.g. Chrome 78.0.3904.108, Node.js 10.17.0): Node 12
  • Operating system and version (desktop or mobile): macOS 10.15.4

Reproducible Demo

(Paste the link to an example repo, including a siteConfig.js, and exact instructions to reproduce the issue.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn error in the Docusaurus core causing instability or issues with its executionhelp wantedAsking for outside help and/or contributions to this particular issue or PR.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions