Skip to content

Commit a31cf02

Browse files
committed
fix: allow pleaseNotify when ping frequency check triggers
When a subscriber calls pleaseNotify, the ping() call could fail with a frequency throttle error even though the feed was recently validated. Add error codes to ErrorResponse and treat PING_TOO_RECENT as success in pleaseNotify since the feed was already confirmed accessible.
1 parent 64937e3 commit a31cf02

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

services/error-response.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
function ErrorResponse(message) {
1+
function ErrorResponse(message, code) {
22
this.message = message;
3+
this.code = code;
34
}
45

56
ErrorResponse.prototype = Object.create(Error.prototype);

services/ping.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ async function checkPingFrequency(resource) {
1515
const dayjs = await getDayjs();
1616
ctsecs = dayjs().diff(resource.whenLastCheck, 'seconds');
1717
if (ctsecs < minsecs) {
18-
throw new ErrorResponse(appMessage.error.ping.tooRecent(minsecs, ctsecs));
18+
throw new ErrorResponse(appMessage.error.ping.tooRecent(minsecs, ctsecs), 'PING_TOO_RECENT');
1919
}
2020
}
2121
}

services/please-notify.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,10 @@ async function pleaseNotify(notifyProcedure, apiurl, protocol, urlList, diffDoma
8080
urlList.map(async(resourceUrl) => {
8181
try {
8282
await ping(resourceUrl);
83-
} catch {
84-
throw new ErrorResponse(appMessages.error.subscription.readResource(resourceUrl));
83+
} catch (err) {
84+
if (err.code !== 'PING_TOO_RECENT') {
85+
throw new ErrorResponse(appMessages.error.subscription.readResource(resourceUrl));
86+
}
8587
}
8688
await notifyApiUrl(notifyProcedure, apiurl, protocol, resourceUrl, diffDomain);
8789
})

0 commit comments

Comments
 (0)