@bobfrankston/mailx-imap 0.1.79 → 0.1.81

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 (3) hide show
  1. package/index.d.ts +0 -1
  2. package/index.js +24 -7
  3. package/package.json +3 -3
package/index.d.ts CHANGED
@@ -395,7 +395,6 @@ export declare class ImapManager extends EventEmitter {
395
395
  * no teal mark). With TTL, transient misses self-heal in 5 minutes;
396
396
  * genuine zombies back off to once-per-12-hour retries — bounded load.
397
397
  * Key shape `${accountId}:${folderId}:${uid}`. */
398
- private prefetchFailures;
399
398
  private markPrefetchEmpty;
400
399
  private isPrefetchEmpty;
401
400
  /** Clear a UID's prefetch-failure record after a successful fetch, so a
package/index.js CHANGED
@@ -2896,14 +2896,18 @@ export class ImapManager extends EventEmitter {
2896
2896
  * no teal mark). With TTL, transient misses self-heal in 5 minutes;
2897
2897
  * genuine zombies back off to once-per-12-hour retries — bounded load.
2898
2898
  * Key shape `${accountId}:${folderId}:${uid}`. */
2899
- prefetchFailures = new Map();
2899
+ // Backed by the persistent `prefetch_failures` table (was an in-memory
2900
+ // Map that every daemon restart wiped — so ghost UIDs re-clogged prefetch
2901
+ // on every launch; Bob 2026-06-01). markPrefetchEmpty/isPrefetchEmpty now
2902
+ // read/write the DB so the 5min→12h backoff survives restarts.
2900
2903
  markPrefetchEmpty(accountId, folderId, uid) {
2901
- const key = `${accountId}:${folderId}:${uid}`;
2902
- const prev = this.prefetchFailures.get(key);
2903
- this.prefetchFailures.set(key, { count: (prev?.count ?? 0) + 1, lastTried: Date.now() });
2904
+ try {
2905
+ this.db.recordPrefetchFailure(accountId, folderId, uid);
2906
+ }
2907
+ catch { /* non-fatal */ }
2904
2908
  }
2905
2909
  isPrefetchEmpty(accountId, folderId, uid) {
2906
- const f = this.prefetchFailures.get(`${accountId}:${folderId}:${uid}`);
2910
+ const f = this.db.getPrefetchFailure(accountId, folderId, uid);
2907
2911
  if (!f)
2908
2912
  return false;
2909
2913
  const backoffMs = f.count <= 1 ? 5 * 60_000
@@ -2919,7 +2923,10 @@ export class ImapManager extends EventEmitter {
2919
2923
  * count and would back off longer than warranted if it ever re-enters
2920
2924
  * the candidate set. */
2921
2925
  clearPrefetchEmpty(accountId, folderId, uid) {
2922
- this.prefetchFailures.delete(`${accountId}:${folderId}:${uid}`);
2926
+ try {
2927
+ this.db.clearPrefetchFailure(accountId, folderId, uid);
2928
+ }
2929
+ catch { /* non-fatal */ }
2923
2930
  }
2924
2931
  /** Background body-cache backfill. Public so the Reconciler can schedule
2925
2932
  * the periodic tick under its priority/back-pressure rules; existing
@@ -2968,7 +2975,17 @@ export class ImapManager extends EventEmitter {
2968
2975
  // BATCH_SIZE rows that all get filtered to zero, and the loop
2969
2976
  // terminates without ever trying live messages further down the
2970
2977
  // size-asc list.
2971
- const raw = this.db.getMessagesWithoutBody(accountId, BATCH_SIZE * 4);
2978
+ // Exclude error-cooled folders AT THE QUERY so a single bloated /
2979
+ // perpetually-failing folder (a stuck server-side Outbox, a 300s
2980
+ // archive) can't fill the entire size-asc batch and starve every
2981
+ // healthy folder. Recomputed each iteration: a folder that trips
2982
+ // its cooldown mid-loop drops out on the next pull (Bob 2026-06-01
2983
+ // "so much unfetched — nothing draining"). Empty when no folder is
2984
+ // cooling, so the common case is unchanged.
2985
+ const coolingFolderIds = this.db.getFolders(accountId)
2986
+ .filter(f => this.shouldSkipFolder(accountId, f.path))
2987
+ .map(f => f.id);
2988
+ const raw = this.db.getMessagesWithoutBody(accountId, BATCH_SIZE * 4, coolingFolderIds);
2972
2989
  const missing = raw.filter(m => !this.isPrefetchEmpty(accountId, m.folderId, m.uid))
2973
2990
  .slice(0, BATCH_SIZE);
2974
2991
  if (missing.length === 0)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/mailx-imap",
3
- "version": "0.1.79",
3
+ "version": "0.1.81",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -11,7 +11,7 @@
11
11
  "dependencies": {
12
12
  "@bobfrankston/mailx-types": "^0.1.18",
13
13
  "@bobfrankston/mailx-settings": "^0.1.26",
14
- "@bobfrankston/mailx-store": "^0.1.42",
14
+ "@bobfrankston/mailx-store": "^0.1.43",
15
15
  "@bobfrankston/iflow-direct": "^0.1.51",
16
16
  "@bobfrankston/tcp-transport": "^0.1.6",
17
17
  "@bobfrankston/smtp-direct": "^0.1.8",
@@ -39,7 +39,7 @@
39
39
  "dependencies": {
40
40
  "@bobfrankston/mailx-types": "^0.1.18",
41
41
  "@bobfrankston/mailx-settings": "^0.1.26",
42
- "@bobfrankston/mailx-store": "^0.1.42",
42
+ "@bobfrankston/mailx-store": "^0.1.43",
43
43
  "@bobfrankston/iflow-direct": "^0.1.51",
44
44
  "@bobfrankston/tcp-transport": "^0.1.6",
45
45
  "@bobfrankston/smtp-direct": "^0.1.8",