LearnNewsExamplesServices
Frontmatter
id19155
titleRebuilding over a sitemap without lastmod dates hangs, and pairs dates across entries
stateClosed
labels
bugaiperformancebuild
assigneesneo-opus-grace
createdAtSep 24, 2026, 2:41 PM
updatedAtSep 24, 2026, 3:02 PM
githubUrlhttps://github.com/neomjs/neo/issues/19155
authorneo-opus-grace
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtSep 24, 2026, 3:02 PM

Rebuilding over a sitemap without lastmod dates hangs, and pairs dates across entries

Closed v13.2.0/archive-v13-2-0-chunk-23 bugaiperformancebuild
neo-opus-grace
neo-opus-grace commented on Sep 24, 2026, 2:41 PM

Context

Found while running neomjs/pages#10's dry runs for neomjs/neo#19047. A second pages build at an unchanged engine version spun at ~100% CPU inside step 7's buildScripts/docs/rebuildContentIndexesAndSeo.mjs, and I killed it after 24 minutes. A pages build writes a sitemap without <lastmod> values ("Git history is shallow or unavailable"), and the next build reads that file back as existingSitemapPath.

Measured on dev@18b473b6e8:

  • getSitemapXml({existingSitemapPath}) over the previous 1.5 MB, 19,293-URL sitemap was stopped by SIGTERM at 45 s.
  • The same call without existingSitemapPath returns in 1 s.

The Problem

getExistingSitemapLastmodMap (buildScripts/docs/seo/generate.mjs:456–471) runs one global pattern over the whole file:

/<url>[\s\S]*?<loc>(.*?)<\/loc>[\s\S]*?<lastmod>(.*?)<\/lastmod>[\s\S]*?<\/url>/g

[\s\S]*? is not bounded by </url>, which causes two faults:

  1. It hangs. When an entry has no <lastmod>, the pattern searches to the end of the document from that entry, and from every later one. A file with no dates at all is scanned quadratically.
  2. It pairs the wrong entries. An entry without <lastmod> takes the next entry's <lastmod>, and that next entry is consumed. For <url><loc>A</loc></url><url><loc>B</loc><lastmod>D</lastmod></url> the map is {A → D}, not {B → D}.

Both have shipped since dde5acf77f (#12261, 2026-05-31), so 13.0.0 and 13.1.0 carry them. In practice, pages' update-neo-version-force hits the hang whenever it re-runs at an unchanged engine version, because the previous lastmod-less sitemap is still in the tree.

The Architectural Reality

  • getSitemapXml (generate.mjs:866) calls the function only when git history is unusable and an existing sitemap path is given (:907–910).
  • The function is module-private and has no spec. test/playwright/unit/buildScripts/docs/seo/Generate.spec.mjs covers the release-note helpers only.

The Fix

Match one <url>…</url> block at a time, then read loc and lastmod inside that block. Map an entry only when both exist. That is linear in the file size, and it never pairs across entries. Export the function so a unit spec can reach it without running git.

Acceptance Criteria

  • AC-1: For an entry without <lastmod> followed by an entry with one, the map holds only the second entry's loc and date. Red on dev.
  • AC-2: A sitemap of thousands of entries without <lastmod> returns an empty map. The speed claim comes from the structure (each block is read once), plus an outside-CI measurement on a real lastmod-less sitemap. No CI timing ceiling.
  • AC-3: A sitemap where every entry is dated still maps each loc to its lastmod. (Corrected 2026-09-24: reading a block with <lastmod> before <loc> is new behaviour. The old pattern required <loc> first, and the generator always writes it first.)

Out of Scope

  • Where lastmod comes from for a corpus copy with no git history. neomjs/pages#10 records that question.
  • The lastmod policy itself (#12259).

Related

neomjs/neo#19047 · neomjs/pages#10 · #12259 / #12261 (origin)

Sweeps at 2026-09-24T12:40Z: neomjs/neo's latest 20 open issues, gh search issues "sitemap lastmod" (hits #19047 and #12964, unrelated), and query_raw_memories("sitemap generation hangs … existing sitemap without lastmod"). No equivalent. The defect note of 12:30Z (fingerprint 0b1715dd13ae5c4e) is promoted here.

Origin Session ID: 1f7129c9-c0f7-42e0-ba47-7a42e5ac57c2 Retrieval Hint: "getExistingSitemapLastmodMap regex lastmod quadratic cross-entry pairing"

🖖 Grace (Claude Opus 5.5, Claude Code) · session 1f7129c9-c0f7-42e0-ba47-7a42e5ac57c2

tobiu referenced in commit 116e561 - "fix(seo): a sitemap without lastmod dates is read one entry at a time (#19155) (#19156) on Sep 24, 2026, 3:02 PM
tobiu closed this issue on Sep 24, 2026, 3:02 PM