Skip to content

fix(npmjs): new versions silently missed due to non-monotonic changes feed - #1935

Merged
cdklabs-automation merged 1 commit into
mainfrom
mrgrain/fix/npmjs/windowed-scan-follower
Sep 23, 2026
Merged

cdklabs-automation merged 1 commit into
mainfrom
mrgrain/fix/npmjs/windowed-scan-follower

Conversation

@mrgrain

@mrgrain mrgrain commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

The npm replica's _changes feed occasionally makes change entries visible behind positions the follower has already read past (npm calls this normal feed behavior), and the registry occasionally serves packuments older than the revision the feed announced. Both cases silently dropped package versions until the affected package published again. In a recent incident, five consecutive construct-hub-probe versions were missed over about 15 hours.

The follower therefore no longer tracks a single high-water mark:

  • It writes a receipt for every change entry it receives, and every run re-scans a trailing window of the feed, processing any entry it has no receipt for. Late-inserted entries are picked up on the next run. Rolling checkpoints map times to feed positions and derive the window's starting point. Interim checkpoints are recorded as a scan progresses, so interrupted scans resume where they stopped; a daily deep scan covers the full state retention, so insertion delays beyond the regular window are still observed.
  • When the registry serves a packument behind the announced revision (a laggy packument), the versions it did serve are processed immediately. The follower records the announced revision and re-checks it every run until it appears or ages out after 24 hours. A give-up is logged with the package name and emits a metric that drives a low-severity alarm, since at that point a version announced by the feed genuinely never materialized.
  • All state lives in one scannable, newline-delimited S3 object (receipts, checkpoints, laggy packuments; roughly 3 MB raw / a few hundred KB gzipped at 24h retention).

Observability: LateChangeCount and LateChangeLag measure the feed's late insertions (the lag data is what tunes the scan window), and LaggyPackuments / LaggyPackumentsRecovered / LaggyPackumentGiveUps track the registry lagging the feed. They feed a new Feed Reliability dashboard widget and two low-severity alarms, both with runbook entries. The PR also adds docs/npm-sync-protocol.md, documenting with citations what the feed does and does not guarantee, and updates the backfill instructions in the application overview for the new state model.

Replaces #1933.

Internal reference: V2376798198


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@mrgrain
mrgrain force-pushed the mrgrain/fix/npmjs/windowed-scan-follower branch from 2cc1e91 to 7732d6c Compare September 22, 2026 14:45
… feed

The npm replica's `_changes` feed occasionally makes change entries
visible behind positions the follower has already read past, and the
registry occasionally serves packuments older than the revision the
feed announced. Both paths silently dropped package versions until the
affected package published again.

The follower no longer tracks a single high-water mark. It keeps a
receipt for every change entry it has received, and every run re-scans
a trailing window of the feed (newest slice first), processing any
entry it has no receipt for. A periodic deep scan covers the full state
retention so insertion delays beyond the regular window are still
observed. When the registry serves a packument behind the announced
revision (a laggy packument), the served versions are processed
immediately and the announced revision is re-checked every run until it
appears or the expectation ages out.

State (receipts, checkpoints, laggy packuments) lives in a single
scannable, newline-delimited S3 object. Existing deployments are
migrated by seeding the first checkpoint from the legacy transaction
marker. New LateChangeCount/LateChangeLag and LaggyPackuments metrics
feed a Feed Reliability dashboard widget and two low-severity alarms.

Internal reference: V2376798198
@mrgrain
mrgrain force-pushed the mrgrain/fix/npmjs/windowed-scan-follower branch from f5eb8c1 to 0ab00ff Compare September 22, 2026 14:55
@9pace
9pace self-requested a review September 22, 2026 17:45
@cdklabs-automation
cdklabs-automation added this pull request to the merge queue Sep 23, 2026
Merged via the queue into main with commit a3a248a Sep 23, 2026
9 checks passed
@cdklabs-automation
cdklabs-automation deleted the mrgrain/fix/npmjs/windowed-scan-follower branch September 23, 2026 08:56
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.

3 participants