Skip to content

Commit 7897c48

Browse files
kaizenccgithub-actions
and
github-actions
authored
fix: npm follower lambda fails on 404 errors (#1689)
the npm follower now makes a GET request for every package it finds. occasionally, that results in a 404 error. we shouldn't fail the entire lambda on these, and instead log and move on. ---- *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 5aee973 commit 7897c48

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-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: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,18 @@ export class CouchChanges extends EventEmitter {
7979

8080
const metadataUrl = new URL(change.id, NPM_REGISTRY_URL);
8181
console.log(`Fetching metadata for ${change.id}: ${metadataUrl}`);
82-
const meta = await this.https('get', metadataUrl);
83-
change.doc = meta; // add metadata to the change object
84-
return change;
82+
83+
try {
84+
const meta = await this.https('get', metadataUrl);
85+
change.doc = meta; // add metadata to the change object
86+
return change;
87+
} catch (e: any) {
88+
if (e.errorMessage.includes('HTTP 404')) {
89+
console.log(`Skipping ${change.id} because of 404 error:\n${e}`);
90+
return;
91+
}
92+
throw e;
93+
}
8594
}
8695

8796
private async fetchAndFilterAllMetadata(
@@ -130,9 +139,7 @@ export class CouchChanges extends EventEmitter {
130139
if (body) {
131140
headers['Content-Type'] = 'application/json';
132141
}
133-
console.log(
134-
`Request: ${method.toUpperCase()} ${url}, ${JSON.stringify(headers)}`
135-
);
142+
136143
const req = request(
137144
url,
138145
{

0 commit comments

Comments
 (0)