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

[ BUG ] Sitemap not generated when url count is less than 5. #419

Closed
vikaskrsharma opened this issue Jan 5, 2024 · 3 comments
Closed

[ BUG ] Sitemap not generated when url count is less than 5. #419

vikaskrsharma opened this issue Jan 5, 2024 · 3 comments

Comments

@vikaskrsharma
Copy link

When generating a sitemap xml using SitemapStream and if number of items write is less than 5 ie number of items passed for url generation is less than 5, generated xml does not show any data. For 5 or more item/urls, it is working fine.

@huntharo
Copy link
Contributor

huntharo commented May 19, 2024

Do you have example code for this?

I ask because:

  • There is literally a test that writes 2 items:
    it('pops out the preamble and closetag', async () => {
    const sms = new SitemapStream();
    sms.write(sampleURLs[0]);
    sms.write(sampleURLs[1]);
    sms.end();
    expect((await streamToPromise(sms)).toString()).toBe(
    preamble +
    `<url><loc>${sampleURLs[0]}/</loc></url>` +
    `<url><loc>${sampleURLs[1]}</loc></url>` +
    closetag
    );
    });
  • I suspect this is a usage error that will be obvious if we can see the example code
  • I have a production system that has been writing arbitrary numbers of items to new sitemap files and has not had an error in 2+ years... not a guarantee that there is no problem, but I think this is pretty solid
  • I am aware that there are lots of gotchas with streams that can cause subtle problems

@huntharo
Copy link
Contributor

@derduher - I think we can close this as a duplicate of #362

@vikaskrsharma
Copy link
Author

@huntharo As i am not working on this project anymore, can't paste the code. but the case was, if i am passing less than 5 url to the SitemapStream, i am getting nothing in sitemap url. but i pass 6 or more url, i was getting sitemap with all urls. As per your test, this case should fail. but when was using it on my env, this was the actual behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants