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:
- 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.
- 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
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
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 asexistingSitemapPath.Measured on
dev@18b473b6e8:getSitemapXml({existingSitemapPath})over the previous 1.5 MB, 19,293-URL sitemap was stopped by SIGTERM at 45 s.existingSitemapPathreturns 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:<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.<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-forcehits 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).test/playwright/unit/buildScripts/docs/seo/Generate.spec.mjscovers the release-note helpers only.The Fix
Match one
<url>…</url>block at a time, then readlocandlastmodinside 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
<lastmod>followed by an entry with one, the map holds only the second entry'slocand date. Red ondev.<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.locto itslastmod. (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
lastmodpolicy 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), andquery_raw_memories("sitemap generation hangs … existing sitemap without lastmod"). No equivalent. The defect note of 12:30Z (fingerprint0b1715dd13ae5c4e) 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