Skip to content

Conversation

@kaizencc
Copy link
Contributor

@kaizencc kaizencc commented Jan 7, 2026

The npm follower grabs information from multiple sources that can be out of sync. This subsequently causes some new package updates to not be identified and sent to ingestion.

Screenshot 2026-01-07 at 6 03 43 PM

Basically, with the new NPM API, our NPM follower ingests information from multiple sources. Occasionally there is a delay between picking up a new change from the NPM changes stream and the change actually showing up in the specific package metadata.

Previously, we would just drop this change altogether as unactionable. Subsequent updates to the package could trigger another metadata lookup that would grab the change, but this results in an indeterminate delay.

Now, we identify that the metadata is out of sync by comparing the sequential part of the rev property. If the metadata rev is below the changes rev, we know it is lagging behind and exponentially retry until the metadata is updated or until 30 seconds (where we then proceed with the out of sync data).

The NPM follower function does some basic math for when to grab the next batch and when to exit and wait for a subsequent lambda execution. Because this change increases the batch time by up to 30 seconds, I have increased the expected worst-case-scenario time by 30 seconds as well.


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

@kaizencc
Copy link
Contributor Author

kaizencc commented Jan 7, 2026

Example logs of local setup with ***** highlighting important logs that make me confident that this fix works.

  | 2026-01-07T22:32:11.247Z | 2026-01-07T22:32:11.247Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Polling changes from npm replica
  | 2026-01-07T22:32:11.394Z | 2026-01-07T22:32:11.394Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Response: GET https://replicate.npmjs.com/registry/_changes?limit=100&since=92427725 => HTTP 200 (OK)
  | 2026-01-07T22:32:11.395Z | 2026-01-07T22:32:11.395Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Fetching metadata for @claude-flow/cli: https://registry.npmjs.org/@claude-flow/cli
  | 2026-01-07T22:32:11.395Z | 2026-01-07T22:32:11.395Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Fetching metadata for @sdjkals/icons-loader-ap7h: https://registry.npmjs.org/@sdjkals/icons-loader-ap7h
  | 2026-01-07T22:32:11.395Z | 2026-01-07T22:32:11.395Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Fetching metadata for @brika/blocks-builtin: https://registry.npmjs.org/@brika/blocks-builtin
  | 2026-01-07T22:32:11.396Z | 2026-01-07T22:32:11.396Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Fetching metadata for @nihaoyaya/core-dist-701s: https://registry.npmjs.org/@nihaoyaya/core-dist-701s
  | 2026-01-07T22:32:11.396Z | 2026-01-07T22:32:11.396Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Fetching metadata for oiu-core: https://registry.npmjs.org/oiu-core
  | 2026-01-07T22:32:11.396Z | 2026-01-07T22:32:11.396Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Fetching metadata for @muxi-ai/muxi-typescript: https://registry.npmjs.org/@muxi-ai/muxi-typescript
  | 2026-01-07T22:32:11.396Z | 2026-01-07T22:32:11.396Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Fetching metadata for @longegeg/font-assets-lite: https://registry.npmjs.org/@longegeg/font-assets-lite
  | 2026-01-07T22:32:11.396Z | 2026-01-07T22:32:11.396Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Fetching metadata for @railway/cli: https://registry.npmjs.org/@railway/cli
  | 2026-01-07T22:32:11.396Z | 2026-01-07T22:32:11.396Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Fetching metadata for @shannonarcher/db-migrate-sql: https://registry.npmjs.org/@shannonarcher/db-migrate-sql
  | 2026-01-07T22:32:11.397Z | 2026-01-07T22:32:11.397Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Fetching metadata for @nihaoyaya/font-driver-687y: https://registry.npmjs.org/@nihaoyaya/font-driver-687y
  | 2026-01-07T22:32:11.436Z | 2026-01-07T22:32:11.436Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Response: GET https://registry.npmjs.org/@claude-flow/cli => HTTP 200 (OK)
  | 2026-01-07T22:32:11.437Z | 2026-01-07T22:32:11.437Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Response: GET https://registry.npmjs.org/@nihaoyaya/font-driver-687y => HTTP 200 (OK)
  | 2026-01-07T22:32:11.438Z | 2026-01-07T22:32:11.438Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Changes database reported revision 28; Latest revision in replica is 28
  | 2026-01-07T22:32:11.438Z | 2026-01-07T22:32:11.438Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Skipping @shannonarcher/db-migrate-sql because of HTTP 404 (Not Found) error
  | 2026-01-07T22:32:11.441Z | 2026-01-07T22:32:11.441Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Response: GET https://registry.npmjs.org/@brika/blocks-builtin => HTTP 200 (OK)
  | 2026-01-07T22:32:11.442Z | 2026-01-07T22:32:11.442Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Changes database reported revision 2; Latest revision in replica is 2
  | 2026-01-07T22:32:11.443Z | 2026-01-07T22:32:11.443Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Response: GET https://registry.npmjs.org/oiu-core => HTTP 200 (OK)
  | 2026-01-07T22:32:11.444Z | 2026-01-07T22:32:11.444Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Changes database reported revision 2; Latest revision in replica is 2
  | 2026-01-07T22:32:11.458Z | 2026-01-07T22:32:11.458Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Response: GET https://registry.npmjs.org/@longegeg/font-assets-lite => HTTP 200 (OK)
  | 2026-01-07T22:32:11.480Z | 2026-01-07T22:32:11.480Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Response: GET https://registry.npmjs.org/@nihaoyaya/core-dist-701s => HTTP 200 (OK)
***** | 2026-01-07T22:32:11.549Z | 2026-01-07T22:32:11.549Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Changes database reported revision 3531; Latest revision in replica is 3530
***** | 2026-01-07T22:32:11.550Z | 2026-01-07T22:32:11.550Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Replica rev 3530 < Changes rev 3531, retrying in 1000 ms
  | 2026-01-07T22:32:11.574Z | 2026-01-07T22:32:11.574Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Changes database reported revision 2428; Latest revision in replica is 2428
  | 2026-01-07T22:32:11.575Z | 2026-01-07T22:32:11.575Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Response: GET https://registry.npmjs.org/@railway/cli => HTTP 200 (OK)
  | 2026-01-07T22:32:11.575Z | 2026-01-07T22:32:11.575Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Response: GET https://registry.npmjs.org/@muxi-ai/muxi-typescript => HTTP 200 (OK)
  | 2026-01-07T22:32:11.576Z | 2026-01-07T22:32:11.576Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Changes database reported revision 3; Latest revision in replica is 3
  | 2026-01-07T22:32:11.617Z | 2026-01-07T22:32:11.617Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Changes **database reported revision 4893; Latest revision in replica is 4892
  | 2026-01-07T22:32:11.617Z | 2026-01-07T22:32:11.617Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Replica rev 4892 < Changes rev 4893, retrying in 1000 ms**
  | 2026-01-07T22:32:11.624Z | 2026-01-07T22:32:11.624Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Changes database reported revision 217; Latest revision in replica is 217
  | 2026-01-07T22:32:11.679Z | 2026-01-07T22:32:11.679Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Response: GET https://registry.npmjs.org/@sdjkals/icons-loader-ap7h => HTTP 200 (OK)
  | 2026-01-07T22:32:11.991Z | 2026-01-07T22:32:11.991Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Changes database reported revision 2432; Latest revision in replica is 2432
  | 2026-01-07T22:32:12.604Z | 2026-01-07T22:32:12.604Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Response: GET https://registry.npmjs.org/@nihaoyaya/font-driver-687y => HTTP 200 (OK)
  | 2026-01-07T22:32:12.659Z | 2026-01-07T22:32:12.659Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Response: GET https://registry.npmjs.org/@longegeg/font-assets-lite => HTTP 200 (OK)
***** | 2026-01-07T22:32:12.745Z | 2026-01-07T22:32:12.745Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Changes database reported revision 3531; Latest revision in replica is 3530
***** | 2026-01-07T22:32:12.745Z | 2026-01-07T22:32:12.745Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Replica rev 3530 < Changes rev 3531, retrying in 2000 ms
***** | 2026-01-07T22:32:12.825Z | 2026-01-07T22:32:12.825Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Changes database reported revision 4893; Latest revision in replica is 4892
***** | 2026-01-07T22:32:12.825Z | 2026-01-07T22:32:12.825Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Replica rev 4892 < Changes rev 4893, retrying in 2000 ms
  | 2026-01-07T22:32:14.799Z | 2026-01-07T22:32:14.799Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Response: GET https://registry.npmjs.org/@nihaoyaya/font-driver-687y => HTTP 200 (OK)
  | 2026-01-07T22:32:14.864Z | 2026-01-07T22:32:14.864Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Response: GET https://registry.npmjs.org/@longegeg/font-assets-lite => HTTP 200 (OK)
***** | 2026-01-07T22:32:14.911Z | 2026-01-07T22:32:14.911Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Changes database reported revision 3531; Latest revision in replica is 3530
***** | 2026-01-07T22:32:14.911Z | 2026-01-07T22:32:14.911Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Replica rev 3530 < Changes rev 3531, retrying in 4000 ms
***** | 2026-01-07T22:32:15.022Z | 2026-01-07T22:32:15.022Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Changes database reported revision 4893; Latest revision in replica is 4892
***** | 2026-01-07T22:32:15.022Z | 2026-01-07T22:32:15.022Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Replica rev 4892 < Changes rev 4893, retrying in 4000 ms
  | 2026-01-07T22:32:18.992Z | 2026-01-07T22:32:18.992Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Response: GET https://registry.npmjs.org/@nihaoyaya/font-driver-687y => HTTP 200 (OK)
  | 2026-01-07T22:32:19.056Z | 2026-01-07T22:32:19.056Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Response: GET https://registry.npmjs.org/@longegeg/font-assets-lite => HTTP 200 (OK)
***** | 2026-01-07T22:32:19.186Z | 2026-01-07T22:32:19.186Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Changes database reported revision 3531; Latest revision in replica is 3530
***** | 2026-01-07T22:32:19.186Z | 2026-01-07T22:32:19.186Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Replica rev 3530 < Changes rev 3531, retrying in 8000 ms
***** | 2026-01-07T22:32:19.250Z | 2026-01-07T22:32:19.250Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Changes database reported revision 4893; Latest revision in replica is 4892
***** | 2026-01-07T22:32:19.251Z | 2026-01-07T22:32:19.251Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Replica rev 4892 < Changes rev 4893, retrying in 8000 ms
  | 2026-01-07T22:32:27.238Z | 2026-01-07T22:32:27.238Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Response: GET https://registry.npmjs.org/@nihaoyaya/font-driver-687y => HTTP 200 (OK)
  | 2026-01-07T22:32:27.292Z | 2026-01-07T22:32:27.292Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Response: GET https://registry.npmjs.org/@longegeg/font-assets-lite => HTTP 200 (OK)
***** | 2026-01-07T22:32:27.357Z | 2026-01-07T22:32:27.357Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Changes database reported revision 3531; Latest revision in replica is 3531
***** | 2026-01-07T22:32:27.528Z | 2026-01-07T22:32:27.528Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Changes database reported revision 4893; Latest revision in replica is 4893
  | 2026-01-07T22:32:27.528Z | 2026-01-07T22:32:27.528Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Received a batch of 10 element(s), 9 after filtering
  | 2026-01-07T22:32:27.550Z | 2026-01-07T22:32:27.550Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO [92427741] Could not find info for the following versions. Were they un-published? @railway/[email protected], @railway/[email protected], @railway/[email protected]
  | 2026-01-07T22:32:27.557Z | 2026-01-07T22:32:27.557Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Identified 0 relevant package version update(s)
  | 2026-01-07T22:32:27.557Z | 2026-01-07T22:32:27.557Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Updating last transaction marker to 92427744
  | 2026-01-07T22:32:27.627Z | 2026-01-07T22:32:27.627Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Successfully updated marker
  | 2026-01-07T22:32:27.627Z | 2026-01-07T22:32:27.627Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO {"StartSeq":92427725,"EndSeq":92427744,"_aws":{"Timestamp":1767825131247,"CloudWatchMetrics":[{"Dimensions":[[]],"Metrics":[{"Name":"NpmJsChangeAge","Unit":"Milliseconds"},{"Name":"PackageVersionCount","Unit":"Count"},{"Name":"BatchProcessingTime","Unit":"Milliseconds"},{"Name":"LastSeq","Unit":"None"},{"Name":"RelevantPackageVersions","Unit":"Count"},{"Name":"RemainingTime","Unit":"Milliseconds"},{"Name":"ChangeCount","Unit":"Count"}],"Namespace":"ConstructHub/PackageSource/NpmJs/Follower"}]},"NpmJsChangeAge":[32101,30516,29912,29855,28867,27893,20700,19712,17602],"PackageVersionCount":[28,2432,2,2428,2,3,4902,209,3531],"BatchProcessingTime":99,"LastSeq":92427744,"RelevantPackageVersions":0,"RemainingTime":263867,"ChangeCount":9}
  | 2026-01-07T22:32:27.628Z | 2026-01-07T22:32:27.628Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Polling changes from npm replica
  | 2026-01-07T22:32:27.756Z | 2026-01-07T22:32:27.756Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Response: GET https://replicate.npmjs.com/registry/_changes?limit=100&since=92427744 => HTTP 200 (OK)
  | 2026-01-07T22:32:27.757Z | 2026-01-07T22:32:27.757Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Received a batch of 0 element(s), 0 after filtering
  | 2026-01-07T22:32:27.757Z | 2026-01-07T22:32:27.757Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Received 0 changes, caught up to "now", exiting...
  | 2026-01-07T22:32:27.757Z | 2026-01-07T22:32:27.757Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Updating last transaction marker to 92427744
  | 2026-01-07T22:32:27.806Z | 2026-01-07T22:32:27.806Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO Successfully updated marker
  | 2026-01-07T22:32:27.807Z | 2026-01-07T22:32:27.807Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO {"StartSeq":92427744,"EndSeq":92427744,"_aws":{"Timestamp":1767825147628,"CloudWatchMetrics":[{"Dimensions":[[]],"Metrics":[{"Name":"ChangeCount","Unit":"Count"},{"Name":"RemainingTime","Unit":"Milliseconds"},{"Name":"BatchProcessingTime","Unit":"Milliseconds"},{"Name":"LastSeq","Unit":"None"}],"Namespace":"ConstructHub/PackageSource/NpmJs/Follower"}]},"ChangeCount":0,"RemainingTime":263687,"BatchProcessingTime":50,"LastSeq":92427744}
  | 2026-01-07T22:32:27.807Z | 2026-01-07T22:32:27.807Z 9847e050-72e6-4495-8d84-cf10dba20994 INFO All done here, we have success!


// The slowest batch processing time so far (starts at 60 seconds). This is how much time should
// be left before timeout if a new batch is to be fetched.
let maxBatchProcessingTime = 30_000;
let maxBatchProcessingTime = 60_000;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The NPM follower function does some basic math for when to grab the next batch and when to exit and wait for a subsequent lambda execution. Because this change increases the batch time by up to 30 seconds, I have increased the expected worst-case-scenario time by 30 seconds as well.

@cdklabs-automation cdklabs-automation added this pull request to the merge queue Jan 8, 2026
Merged via the queue into main with commit 68000b4 Jan 8, 2026
7 checks passed
@cdklabs-automation cdklabs-automation deleted the conroy/revs branch January 8, 2026 09:25
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