Skip to content

Commit 37adf2a

Browse files
kaizenccgithub-actions
and
github-actions
authored
fix: npm follower ignores 404 errors correctly (#1690)
Follow up to #1689 that did not do this correctly. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --------- Signed-off-by: github-actions <github-actions@github.com> Co-authored-by: github-actions <github-actions@github.com>
1 parent 7897c48 commit 37adf2a

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

src/__tests__/__snapshots__/construct-hub.test.ts.snap

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/__tests__/devapp/__snapshots__/snapshot.test.ts.snap

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/package-sources/npmjs/couch-changes.lambda-shared.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const NPM_REGISTRY_URL = 'https://registry.npmjs.org/';
1515
export class CouchChanges extends EventEmitter {
1616
private readonly agent: Agent;
1717
private readonly baseUrl: URL;
18-
private readonly databaseUrl: URL;
18+
private readonly database: string;
1919

2020
/**
2121
* @param baseUrl the CouchDB endpoint URL.
@@ -31,7 +31,7 @@ export class CouchChanges extends EventEmitter {
3131
timeout: 60_000,
3232
});
3333
this.baseUrl = new URL(baseUrl);
34-
this.databaseUrl = new URL(database, baseUrl);
34+
this.database = database;
3535
}
3636

3737
/**
@@ -55,7 +55,7 @@ export class CouchChanges extends EventEmitter {
5555
): Promise<DatabaseChanges> {
5656
const batchSize = opts?.batchSize ?? 100;
5757

58-
const changesUrl = new URL('_changes', this.databaseUrl);
58+
const changesUrl = new URL(this.database, this.baseUrl);
5959
changesUrl.searchParams.set('limit', batchSize.toFixed());
6060
changesUrl.searchParams.set('since', since.toString());
6161

@@ -85,8 +85,10 @@ export class CouchChanges extends EventEmitter {
8585
change.doc = meta; // add metadata to the change object
8686
return change;
8787
} catch (e: any) {
88-
if (e.errorMessage.includes('HTTP 404')) {
89-
console.log(`Skipping ${change.id} because of 404 error:\n${e}`);
88+
if (e.message?.includes('HTTP 404')) {
89+
console.log(
90+
`Skipping ${change.id} because of HTTP 404 (Not Found) error`
91+
);
9092
return;
9193
}
9294
throw e;

src/package-sources/npmjs/npm-js-follower.lambda.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export async function handler(event: ScheduledEvent, context: Context) {
7979
const denyList = await DenyListClient.newClient();
8080
const licenseList = await LicenseListClient.newClient();
8181

82-
const npm = new CouchChanges(NPM_REPLICA_REGISTRY_URL, 'registry');
82+
const npm = new CouchChanges(NPM_REPLICA_REGISTRY_URL, 'registry/_changes');
8383

8484
const { marker: initialMarker, knownVersions } =
8585
await loadLastTransactionMarker(stagingBucket, npm);

0 commit comments

Comments
 (0)