@evanp/activitypub-bot 0.45.3 → 0.45.4

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.
package/CHANGELOG.md CHANGED
@@ -9,6 +9,12 @@ and this project adheres to
9
9
 
10
10
  ## [Unreleased]
11
11
 
12
+ ## [0.45.4] - 2026-04-26
13
+
14
+ ### Fixed
15
+
16
+ - Retry throttled deliveries
17
+
12
18
  ## [0.45.3] - 2026-04-24
13
19
 
14
20
  ### Fixed
@@ -2,6 +2,7 @@ import assert from 'node:assert'
2
2
 
3
3
  import as2 from './activitystreams.js'
4
4
  import { Worker, RecoverableError } from './worker.js'
5
+ import { ThrottleError } from './requestthrottler.js'
5
6
 
6
7
  export class DistributionWorker extends Worker {
7
8
  static #MAX_ATTEMPTS = 21 // ~24 days
@@ -21,6 +22,12 @@ export class DistributionWorker extends Worker {
21
22
  this._logger.info({ activity: activity.id, inbox }, 'Delivered activity')
22
23
  } catch (err) {
23
24
  if (!err.status) {
25
+ if (err instanceof ThrottleError) {
26
+ this._logger.warn(
27
+ { err, activity: activity.id, inbox },
28
+ 'Throttled delivery, waiting to retry')
29
+ throw new RecoverableError(err.message, err.waitTime)
30
+ }
24
31
  this._logger.warn(
25
32
  { err, activity: activity.id, inbox },
26
33
  'Could not deliver activity and no HTTP status available')
@@ -3,6 +3,14 @@ import assert from 'node:assert'
3
3
 
4
4
  const BETA = 0.75
5
5
 
6
+ export class ThrottleError extends Error {
7
+ constructor (message, waitTime) {
8
+ super(message)
9
+ this.name = this.constructor.name
10
+ this.waitTime = waitTime
11
+ }
12
+ }
13
+
6
14
  export class RequestThrottler {
7
15
  #connection
8
16
  #logger
@@ -19,7 +27,10 @@ export class RequestThrottler {
19
27
  assert.strictEqual(typeof maxWaitTime, 'number')
20
28
  const waitTime = await this.#getWaitTime(host, maxWaitTime)
21
29
  if (waitTime > maxWaitTime) {
22
- throw new Error(`Wait time is too long; ${waitTime} > ${maxWaitTime}`)
30
+ throw new ThrottleError(
31
+ `Wait time is too long; ${waitTime} > ${maxWaitTime}`,
32
+ waitTime
33
+ )
23
34
  }
24
35
  if (waitTime > 0) {
25
36
  await this.#decrement(host)
package/lib/worker.js CHANGED
@@ -2,7 +2,12 @@ import assert from 'node:assert'
2
2
  import { nanoid } from 'nanoid'
3
3
 
4
4
  export class RecoverableError extends Error {
5
- delay = 1000
5
+ delay
6
+ constructor (message, delay = 1000) {
7
+ super(message)
8
+ this.name = this.constructor.name
9
+ this.delay = delay
10
+ }
6
11
  }
7
12
 
8
13
  export class Worker {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evanp/activitypub-bot",
3
- "version": "0.45.3",
3
+ "version": "0.45.4",
4
4
  "description": "server-side ActivityPub bot framework",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",