Skip to content

feat(utils): add streaming sitemap parsers - #635

Merged
harlan-zw merged 1 commit into
mainfrom
perf/streaming-sitemap-parser
Jul 21, 2026
Merged

harlan-zw merged 1 commit into
mainfrom
perf/streaming-sitemap-parser

Conversation

@harlan-zw

Copy link
Copy Markdown
Collaborator

🔗 Linked issue

Related to #634

❓ Type of change

  • 📖 Documentation
  • 🐞 Bug fix
  • 👌 Enhancement
  • ✨ New feature
  • 🧹 Chore
  • ⚠️ Breaking change

📚 Description

Large sitemap feeds currently buffer the response and build a full fast-xml-parser tree before callers can cap results. parseSitemapStream accepts Response.body, reports the document kind before entries, and cancels unread bytes when iteration stops. A direct fast path moves the 10,000 URL regular parser benchmark from 74.8 ms to 6.8 ms.

⚠️ Breaking Changes

A well-formed empty <urlset> now returns { urls: [], warnings: [] } from parseSitemapXml instead of throwing.

📝 Migration

Remove wrappers that identify empty URL sets from parser error messages. Handle an empty urls array directly.

Parse URL sets and sitemap indexes from Response.body with bounded buffers and cancellation when consumers stop early. Keep the regular parser fast with a direct path for common URL entries.

BREAKING CHANGE: parseSitemapXml now returns an empty result for a well-formed empty urlset instead of throwing.
@pkg-pr-new

pkg-pr-new Bot commented Jul 21, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@nuxtjs/sitemap@635

commit: 0e41252

@harlan-zw harlan-zw changed the title feat(utils)!: add streaming sitemap parsers feat(utils): add streaming sitemap parsers Jul 21, 2026
@harlan-zw
harlan-zw merged commit 77f9c51 into main Jul 21, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant