@hhkaos/webmentions-widget 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bin/snapshot.js +10 -3
  2. package/package.json +1 -1
package/bin/snapshot.js CHANGED
@@ -23,8 +23,9 @@ import {getSnapshotMentions, mergeSnapshot, parseWebmentionJson} from '../src/co
23
23
  const DEFAULT_API = 'https://webmention.io/api/mentions.jf2';
24
24
  const PER_PAGE = 100;
25
25
  const PAGE_DELAY_MS = 500;
26
- const RETRIES = 4;
27
- const RETRY_DELAY_MS = 2000;
26
+ const RETRIES = 8;
27
+ const RETRY_DELAY_MS = 3000;
28
+ const MAX_RETRY_DELAY_MS = 30000;
28
29
 
29
30
  function parseArgs(argv) {
30
31
  const args = {};
@@ -61,7 +62,13 @@ async function fetchPage(url) {
61
62
 
62
63
  for (let attempt = 0; attempt <= RETRIES; attempt += 1) {
63
64
  if (attempt > 0) {
64
- await wait(RETRY_DELAY_MS * 2 ** (attempt - 1));
65
+ // Capped exponential backoff with jitter. webmention.io has spent today
66
+ // failing roughly two requests in three, so a job that gives up after
67
+ // half a minute loses the coin flip often enough to skip whole days; a
68
+ // daily job can afford to be patient for a couple of minutes instead.
69
+ const backoff = Math.min(RETRY_DELAY_MS * 2 ** (attempt - 1), MAX_RETRY_DELAY_MS);
70
+
71
+ await wait(backoff + Math.random() * 1000);
65
72
  }
66
73
 
67
74
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hhkaos/webmentions-widget",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Framework-agnostic, dependency-free widget to fetch and render webmention.io mentions for the current page.",
5
5
  "type": "module",
6
6
  "license": "MIT",