@bobfrankston/rmfmail 1.2.48 → 1.2.49

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.
@@ -24,15 +24,13 @@ const SMTP_PORT_STARTTLS = 587;
24
24
  const SMTP_PORT_IMPLICIT_TLS = 465;
25
25
 
26
26
  type OpsTask = () => Promise<void>;
27
- interface OpsQueue {
28
- fast: OpsTask[];
29
- slow: OpsTask[];
30
- /** Whether the fast lane is currently draining a task. Independent of
31
- * `runningSlow` both lanes can drain concurrently because each uses
32
- * its own connection (fastClient vs. opsClient). C123: the second
33
- * connection is lazy-allocated on the first fast-lane task. */
34
- runningFast: boolean;
35
- runningSlow: boolean;
27
+ /** One FIFO task queue per (account, lane). All lanes drain concurrently —
28
+ * each lane runs on its own persistent connection — so a slow op on one lane
29
+ * never blocks another. Within a lane, strictly sequential (one IMAP command
30
+ * in flight, no SELECT races). */
31
+ interface LaneQueue {
32
+ tasks: OpsTask[];
33
+ running: boolean;
36
34
  }
37
35
  interface HostSemaphore {
38
36
  permits: number;
@@ -591,39 +589,45 @@ export class ImapManager extends EventEmitter {
591
589
  // No semaphore, no pool, no per-operation connect/disconnect.
592
590
  // IDLE uses a separate connection (see startWatching).
593
591
 
594
- /** Persistent slow-lane operational connection per account. Used by sync,
595
- * prefetch, outbox-append, large backfills, and any other "this might
596
- * take a while" operation. */
597
- private opsClients = new Map<string, any>();
598
- /** Lazy-allocated fast-lane client per account (C123). Lives alongside
599
- * `opsClients` so click-time body fetches and flag toggles don't have
600
- * to wait behind a multi-minute prefetch / backfill on the slow client.
601
- * Created on the first fast-lane `withConnection` call; reused while
602
- * alive; recreated on stale-detect or error-discard like opsClients.
603
- * Costs +1 IMAP socket per active account, well under any reasonable
604
- * per-user-IP cap (Dovecot's default is 20). */
605
- private fastClients = new Map<string, any>();
606
- /** Two-lane operation queue per account interactive ops (body fetch on
607
- * click, flag toggle) drain before background ops (sync, prefetch). FIFO
608
- * within each lane. The single ops connection means there's never a race
609
- * on which folder is SELECTed; commands run strictly sequentially. */
610
- private opsQueues = new Map<string, OpsQueue>();
592
+ /** Per-workload connection lanes. Each (lane, account) gets its OWN
593
+ * persistent IMAP connection so a slow op on one lane can't block another:
594
+ * a 90s `SELECT Sent` on "outbox" or a giant `UID FETCH` on "prefetch" no
595
+ * longer wedges INBOX sync/backfill on "sync". This is the root fix for
596
+ * the "whole sync worker goes silent" wedge (Bob 2026-06-20): before, all
597
+ * background work shared ONE slow connection and serialized behind the
598
+ * slowest command (a 90s SELECT Sent / a giant prefetch FETCH stalled
599
+ * INBOX backfill behind it). Lanes in use:
600
+ * fast — interactive: body fetch on click, flag toggle, move
601
+ * slow — folder sync + set-diff backfill (the `{slow:true}` default)
602
+ * prefetch background body download (heaviest, longest)
603
+ * outbox — send + sent-sweep + Outbox/Sent SELECT/APPEND
604
+ * Per account that's ≤4 persistent sockets + 1 IDLE, under Dovecot's 20.
605
+ * laneName (accountId persistent client). */
606
+ private laneClients = new Map<string, Map<string, any>>();
607
+ /** Per-account, per-lane FIFO task queues. accountId (laneName → queue).
608
+ * All lanes for an account drain concurrently (each on its own socket);
609
+ * within a lane, strictly sequential — no SELECT race. */
610
+ private laneQueues = new Map<string, Map<string, LaneQueue>>();
611
611
  /** Per-host semaphore — caps simultaneous IMAP socket opens to one server.
612
- * Defensive guardrail: with the single-ops-per-account model an individual
613
- * user's mailx never hits more than (#accounts × 2) sockets per host, well
614
- * under any reasonable server cap. Exists for the multi-account-on-one-host
615
- * case (e.g. bobma + bobma2 both on imap.iecc.com). */
612
+ * Defensive guardrail for the multi-account-on-one-host case (e.g. bobma +
613
+ * bobma2 both on imap.iecc.com). NOTE: the permit is held for the
614
+ * connection's LIFETIME (released on logout/destroy), not just the open —
615
+ * so this also bounds the number of live persistent connections per host.
616
+ * Each account now keeps up to 4 persistent lanes (fast/slow/prefetch/
617
+ * outbox) + 1 IDLE (IDLE bypasses the semaphore). 8 permits covers two
618
+ * accounts' lanes with headroom, still far under Dovecot's ~20/user+IP. */
616
619
  private hostSemaphores = new Map<string, HostSemaphore>();
617
- private static readonly HOST_PERMITS = 4;
618
-
619
- /** Get (or create) a persistent connection for an account on the named
620
- * lane. Two lanes today: `slow` (the original `opsClients` map — sync,
621
- * prefetch, backfill, outbox) and `fast` (the C123 `fastClients` map —
622
- * click-time body fetch, flag toggles, anything user-driven). Same
623
- * stale-detect + reconnect semantics on both. logout() is wrapped as a
624
- * no-op so legacy callers don't close the persistent client. */
625
- private async getLaneClient(accountId: string, lane: "fast" | "slow"): Promise<any> {
626
- const map = lane === "fast" ? this.fastClients : this.opsClients;
620
+ private static readonly HOST_PERMITS = 8;
621
+
622
+ /** The (accountId → client) map for a lane, created on first use. */
623
+ private laneClientMap(lane: string): Map<string, any> {
624
+ let m = this.laneClients.get(lane);
625
+ if (!m) { m = new Map(); this.laneClients.set(lane, m); }
626
+ return m;
627
+ }
628
+
629
+ private async getLaneClient(accountId: string, lane: string): Promise<any> {
630
+ const map = this.laneClientMap(lane);
627
631
  let client = map.get(accountId);
628
632
  if (client) {
629
633
  // C38: health-check the cached client before returning. If the
@@ -640,7 +644,7 @@ export class ImapManager extends EventEmitter {
640
644
  console.log(` [conn] ${accountId}: stale ${lane} client detected — reconnecting`);
641
645
  client = undefined as any;
642
646
  }
643
- client = await this.newClient(accountId, lane === "fast" ? "fast" : "ops");
647
+ client = await this.newClient(accountId, lane);
644
648
  // Wrap logout as no-op — this is a persistent connection. The
645
649
  // newClient wrapper's close-counter runs on `_realLogout`.
646
650
  const realLogout = client.logout.bind(client);
@@ -657,33 +661,30 @@ export class ImapManager extends EventEmitter {
657
661
  return this.getLaneClient(accountId, "slow");
658
662
  }
659
663
 
660
- /** Run an operation on the account's connection — queued, sequential, no concurrency */
661
- /** Run an operation against the account's single ops connection. Tasks
662
- * queue strictly sequentially per account only one IMAP command in
663
- * flight at a time. This eliminates the SELECT-races and "stale client
664
- * recovery" paths the old multi-client design needed.
664
+ /** Run an operation against one of the account's per-workload lane
665
+ * connections. Tasks queue strictly sequentially WITHIN a lane (one IMAP
666
+ * command in flight, no SELECT race) but lanes run CONCURRENTLY, each on
667
+ * its own socket — so a slow op on one lane never blocks another.
665
668
  *
666
- * Default lane is `fast` covers virtually everything (body fetch,
667
- * flag toggle, move, incremental sync). Pass `slow: true` only for
668
- * operations the caller knows will take a long time and shouldn't
669
- * block the user (multi-folder prefetch batches, large backfills).
670
- * When both lanes have tasks, fast drains first.
669
+ * Pick the lane via `opts.lane` (e.g. "sync", "prefetch", "outbox").
670
+ * Default is "fast" interactive ops (body fetch on click, flag toggle,
671
+ * move). `slow: true` is a legacy alias for the "slow" misc lane; prefer
672
+ * a named lane so distinct workloads don't serialize behind each other.
671
673
  *
672
- * Within a lane, FIFO. The running task always finishes — IMAP can't
673
- * preempt a command mid-flight. */
674
+ * The running task always finishes — IMAP can't preempt a command
675
+ * mid-flight; the wall-clock timeout below bounds how long that can be. */
674
676
  async withConnection<T>(
675
677
  accountId: string,
676
678
  fn: (client: any) => Promise<T>,
677
- opts: { slow?: boolean; timeoutMs?: number } = {},
679
+ opts: { slow?: boolean; lane?: string; timeoutMs?: number } = {},
678
680
  ): Promise<T> {
679
- let queue = this.opsQueues.get(accountId);
680
- if (!queue) {
681
- queue = { fast: [], slow: [], runningFast: false, runningSlow: false };
682
- this.opsQueues.set(accountId, queue);
683
- }
684
- const lane: "fast" | "slow" = opts.slow ? "slow" : "fast";
681
+ const lane: string = opts.lane ?? (opts.slow ? "slow" : "fast");
682
+ let perAccount = this.laneQueues.get(accountId);
683
+ if (!perAccount) { perAccount = new Map(); this.laneQueues.set(accountId, perAccount); }
684
+ let queue = perAccount.get(lane);
685
+ if (!queue) { queue = { tasks: [], running: false }; perAccount.set(lane, queue); }
685
686
  // Per-task wall-clock cap. Without one, a wedged IMAP command (TCP
686
- // half-open, server stalled mid-FETCH) keeps the queue's running flag
687
+ // half-open, server stalled mid-FETCH) keeps the lane's running flag
687
688
  // set forever and every subsequent same-lane task — including the
688
689
  // retry button the user just hit — waits behind it. Default is
689
690
  // generous; callers driving user-visible reads pass a tighter value.
@@ -703,13 +704,12 @@ export class ImapManager extends EventEmitter {
703
704
  resolve(result);
704
705
  } catch (e: any) {
705
706
  clearTimeout(timer);
706
- // Discard the lane's client on any error — a half-broken
707
- // socket poisons every subsequent request on that lane.
708
- // Don't touch the OTHER lane's client; the lanes are
709
- // independent. Destroy synchronously kills the in-flight
710
- // command's socket so the underlying promise rejects and
711
- // stops holding state.
712
- const map = lane === "fast" ? this.fastClients : this.opsClients;
707
+ // Discard THIS lane's client on any error — a half-broken
708
+ // socket poisons every subsequent request on the lane.
709
+ // Other lanes' clients are independent and untouched.
710
+ // Destroy synchronously kills the in-flight command's
711
+ // socket so the underlying promise rejects.
712
+ const map = this.laneClientMap(lane);
713
713
  const stale = map.get(accountId);
714
714
  map.delete(accountId);
715
715
  if (stale) {
@@ -719,31 +719,27 @@ export class ImapManager extends EventEmitter {
719
719
  reject(e);
720
720
  }
721
721
  };
722
- queue![lane].push(task);
722
+ queue!.tasks.push(task);
723
723
  this.drainOpsQueue(accountId);
724
724
  });
725
725
  }
726
726
 
727
- /** Run the next queued task on each lane. Fast and slow lanes drain
728
- * CONCURRENTLY — each on its own connection (C123). FIFO within each
729
- * lane. The running flag per lane prevents reentrant draining of the
730
- * same lane. */
727
+ /** Drain the next queued task on EVERY lane for the account. Lanes run
728
+ * concurrently — each on its own connection and the per-lane running
729
+ * flag prevents reentrant draining of the same lane. */
731
730
  private drainOpsQueue(accountId: string): void {
732
- const queue = this.opsQueues.get(accountId);
733
- if (!queue) return;
734
- const drainLane = (lane: "fast" | "slow"): void => {
735
- const runningKey = lane === "fast" ? "runningFast" : "runningSlow";
736
- if (queue[runningKey]) return;
737
- const next = queue[lane].shift();
738
- if (!next) return;
739
- queue[runningKey] = true;
731
+ const perAccount = this.laneQueues.get(accountId);
732
+ if (!perAccount) return;
733
+ for (const queue of perAccount.values()) {
734
+ if (queue.running) continue;
735
+ const next = queue.tasks.shift();
736
+ if (!next) continue;
737
+ queue.running = true;
740
738
  next().finally(() => {
741
- queue[runningKey] = false;
742
- drainLane(lane);
739
+ queue.running = false;
740
+ this.drainOpsQueue(accountId);
743
741
  });
744
- };
745
- drainLane("fast");
746
- drainLane("slow");
742
+ }
747
743
  }
748
744
 
749
745
  /** Acquire one slot of the per-host connection semaphore. Returns a release
@@ -853,7 +849,7 @@ export class ImapManager extends EventEmitter {
853
849
  * so the server's connection slots free immediately rather than
854
850
  * waiting for socket idle timeouts. */
855
851
  async closeAllClients(accountId: string): Promise<void> {
856
- for (const map of [this.opsClients, this.fastClients]) {
852
+ for (const map of this.laneClients.values()) {
857
853
  const c = map.get(accountId);
858
854
  map.delete(accountId);
859
855
  if (c) { try { await (c._realLogout || c.logout)(); } catch { /* */ } try { c.destroy?.(); } catch { /* */ } }
@@ -871,7 +867,7 @@ export class ImapManager extends EventEmitter {
871
867
  /** Disconnect the persistent operational connections (both lanes) for
872
868
  * an account. */
873
869
  async disconnectOps(accountId: string): Promise<void> {
874
- for (const [name, map] of [["ops", this.opsClients], ["fast", this.fastClients]] as const) {
870
+ for (const [name, map] of this.laneClients) {
875
871
  const client = map.get(accountId);
876
872
  map.delete(accountId);
877
873
  if (client) {
@@ -2524,12 +2520,15 @@ export class ImapManager extends EventEmitter {
2524
2520
  return stored;
2525
2521
  }
2526
2522
 
2527
- /** Kill and recreate the persistent ops connection */
2523
+ /** Kill and recreate the persistent connections for an account — drops the
2524
+ * client on every lane so the next task on each reconnects fresh. */
2528
2525
  private async reconnectOps(accountId: string): Promise<void> {
2529
- const old = this.opsClients.get(accountId);
2530
- this.opsClients.delete(accountId);
2531
- if (old) { try { await (old._realLogout || old.logout)(); } catch { /* */ } }
2532
- console.log(` [conn] ${accountId}: reconnecting`);
2526
+ for (const map of this.laneClients.values()) {
2527
+ const old = map.get(accountId);
2528
+ map.delete(accountId);
2529
+ if (old) { try { await (old._realLogout || old.logout)(); } catch { /* */ } }
2530
+ }
2531
+ console.log(` [conn] ${accountId}: reconnecting (all lanes)`);
2533
2532
  }
2534
2533
 
2535
2534
  /** Handle sync errors — classify and emit appropriate UI events.
@@ -3562,7 +3561,7 @@ export class ImapManager extends EventEmitter {
3562
3561
  })());
3563
3562
  });
3564
3563
  await Promise.all(pending);
3565
- }, { slow: true, timeoutMs: 300_000 });
3564
+ }, { lane: "prefetch", timeoutMs: 300_000 });
3566
3565
  // 5-min cap, not the 90s interactive default:
3567
3566
  // prefetch is background, and a 25-message body
3568
3567
  // chunk on a slow Dovecot legitimately runs past
@@ -4326,7 +4325,7 @@ export class ImapManager extends EventEmitter {
4326
4325
  await this.withConnection(accountId, async (client) => {
4327
4326
  await client.createmailbox("Outbox");
4328
4327
  await this.syncFolders(accountId, client);
4329
- });
4328
+ }, { lane: "outbox" });
4330
4329
  } catch (e: any) {
4331
4330
  // Might already exist — benign
4332
4331
  if (!e.message?.includes("already exists")) throw e;
@@ -4437,7 +4436,7 @@ export class ImapManager extends EventEmitter {
4437
4436
  await this.withConnection(accountId, async (client) => {
4438
4437
  appendedUid = await client.appendMessage(outboxPath, rawMessage, ["\\Seen"]);
4439
4438
  console.log(` [outbox] Queued message in ${outboxPath}${appendedUid != null ? ` (UID ${appendedUid})` : ""}`);
4440
- });
4439
+ }, { lane: "outbox" });
4441
4440
  if (outboxFolder) {
4442
4441
  if (appendedUid != null) {
4443
4442
  // Inserts the row from the source bytes we already have +
@@ -4644,7 +4643,9 @@ export class ImapManager extends EventEmitter {
4644
4643
  // claim so the recovery sweeper picks it up next tick.
4645
4644
  try {
4646
4645
  const outboxPath = await this.ensureOutbox(accountId);
4647
- const client = await this.createClientWithLimit(accountId);
4646
+ // Outbox lane, not the slow/sync lane — a wedged APPEND here (which
4647
+ // withTimeout force-closes the socket on) must not disrupt sync.
4648
+ const client = await this.getLaneClient(accountId, "outbox");
4648
4649
  try {
4649
4650
  for (const { dir, file } of filesToSend) {
4650
4651
  const filePath = path.join(dir, file);
@@ -4780,9 +4781,9 @@ export class ImapManager extends EventEmitter {
4780
4781
  const account = settings.accounts.find(a => a.id === accountId);
4781
4782
  if (!account) return;
4782
4783
 
4783
- // List UIDs first — quick command, fast lane.
4784
+ // List UIDs first — quick command on the dedicated outbox lane.
4784
4785
  const uids = await this.withConnection(accountId, (client) =>
4785
- client.getUids(outboxFolder.path)
4786
+ client.getUids(outboxFolder.path), { lane: "outbox" }
4786
4787
  ) as number[];
4787
4788
  if (uids.length === 0) return;
4788
4789
 
@@ -4792,9 +4793,9 @@ export class ImapManager extends EventEmitter {
4792
4793
  const sentFolder = this.findFolder(accountId, "sent");
4793
4794
 
4794
4795
  for (const uid of uids) {
4795
- // Each iteration is one slow-lane turn — fast-lane work can run
4796
- // between iterations, so a body click during a long outbox drain
4797
- // gets serviced promptly.
4796
+ // Each iteration is one outbox-lane turn — sync, prefetch and
4797
+ // fast-lane (click) work all run on their own connections, so a
4798
+ // long outbox drain never blocks them.
4798
4799
  const result = await this.withConnection(accountId, async (client) => {
4799
4800
  const flags = await client.getFlags(outboxFolder.path, uid);
4800
4801
 
@@ -4842,7 +4843,7 @@ export class ImapManager extends EventEmitter {
4842
4843
  return { skip: true };
4843
4844
  }
4844
4845
  return { source: msg.source };
4845
- }, { slow: true });
4846
+ }, { lane: "outbox" });
4846
4847
 
4847
4848
  if ((result as any).skip) continue;
4848
4849
  const source = (result as any).source as string;
@@ -4858,13 +4859,13 @@ export class ImapManager extends EventEmitter {
4858
4859
  await this.withConnection(accountId, async (client) => {
4859
4860
  // Delete FIRST to prevent double-send if Sent-copy fails.
4860
4861
  await client.deleteMessageByUid(outboxFolder.path, uid);
4861
- }, { slow: true });
4862
+ }, { lane: "outbox" });
4862
4863
  if (sentFolder) {
4863
4864
  let appendedSentUid: number | null = null;
4864
4865
  try {
4865
4866
  await this.withConnection(accountId, async (client) => {
4866
4867
  appendedSentUid = await client.appendMessage(sentFolder.path, source, ["\\Seen"]);
4867
- }, { slow: true });
4868
+ }, { lane: "outbox" });
4868
4869
  } catch (sentErr: any) {
4869
4870
  console.error(` [outbox] Failed to copy to Sent: ${sentErr.message} — message was sent successfully`);
4870
4871
  }
@@ -4894,7 +4895,7 @@ export class ImapManager extends EventEmitter {
4894
4895
  await this.withConnection(accountId, async (client) => {
4895
4896
  await client.removeFlags(outboxFolder.path, uid, [sendingFlag]);
4896
4897
  await client.addFlags(outboxFolder.path, uid, ["$Failed"]);
4897
- }, { slow: true });
4898
+ }, { lane: "outbox" });
4898
4899
  } catch { /* best-effort */ }
4899
4900
  // Suppress the banner for transient network errors. ETIMEDOUT
4900
4901
  // on a Dovecot send is the server being slow / a TCP idle
@@ -5033,10 +5034,10 @@ export class ImapManager extends EventEmitter {
5033
5034
  this.outboxBackoffDelay.delete(accountId);
5034
5035
  } catch (e: any) {
5035
5036
  // Stale-socket errors (Dovecot silently drops idle connections,
5036
- // or the sync path timed out and destroyed the socket): force a
5037
- // fresh ops client so the next tick doesn't keep hitting the same
5038
- // dead socket. Without reconnectOps, the dead client stays in the
5039
- // opsClients map and every subsequent processOutbox call fails
5037
+ // or the sync path timed out and destroyed the socket): force
5038
+ // fresh lane clients so the next tick doesn't keep hitting the
5039
+ // same dead socket. Without reconnectOps, the dead client stays
5040
+ // in its lane map and every subsequent processOutbox call fails
5040
5041
  // immediately with "Not connected" — forever.
5041
5042
  const msg = String(e?.message || e);
5042
5043
  if (/Not connected|ECONNRESET|socket hang up|EPIPE|write after end/i.test(msg)) {
@@ -5136,19 +5137,18 @@ export class ImapManager extends EventEmitter {
5136
5137
  if (rows.length === 0) return;
5137
5138
  let reconciled = 0;
5138
5139
  let appended = 0;
5139
- // Use a DEDICATED IMAP client for sent-sweep do NOT share the
5140
- // slow-lane ops client. The priority-INBOX sync grabs the slow-lane
5141
- // client via getOpsClient() (no lane queueing) and runs SEARCH→FETCH
5142
- // as a logical transaction; if sent-sweep's searchByHeader (SELECT
5143
- // Sent SEARCH CLOSE) interleaves on the same wire between the
5144
- // sync's SEARCH and FETCH, the FETCH lands with no mailbox selected
5145
- // and Dovecot returns "BAD No mailbox selected" — new mail never
5146
- // lands locally (Bob 2026-05-25: "not seeing recent mail").
5147
- // iflow-direct serializes per-command, not per-task, so reusing the
5148
- // shared client is unsafe across logical transactions. A dedicated
5149
- // client is the smallest surgical fix.
5150
- const client = await this.createClientWithLimit(accountId);
5151
- try {
5140
+ // Run the whole sweep on the dedicated "outbox" lane its OWN
5141
+ // persistent connection, separate from the slow/sync lane. Two reasons:
5142
+ // 1. Sent-sweep's `SELECT Sent` has been observed taking 90s on this
5143
+ // server; on the shared slow lane that stalled INBOX sync/backfill
5144
+ // behind it (the "whole worker goes silent" wedge, Bob 2026-06-20).
5145
+ // 2. withConnection serializes the entire SEARCH→APPEND sweep on one
5146
+ // connection, so it can't interleave mid-transaction with another
5147
+ // task's SELECT (the "BAD No mailbox selected" class, Bob
5148
+ // 2026-05-25). Previously this used createClientWithLimit() which
5149
+ // actually returned the SHARED slow client and then destroyed it in
5150
+ // a finally, the opposite of "dedicated".
5151
+ await this.withConnection(accountId, async (client) => {
5152
5152
  for (const row of rows) {
5153
5153
  const msgId = row.message_id;
5154
5154
  if (!msgId) continue;
@@ -5185,10 +5185,7 @@ export class ImapManager extends EventEmitter {
5185
5185
  }
5186
5186
  }
5187
5187
  }
5188
- } finally {
5189
- try { await (client._realLogout || client.logout)(); } catch { /* */ }
5190
- try { client.destroy?.(); } catch { /* */ }
5191
- }
5188
+ }, { lane: "outbox", timeoutMs: 120_000 });
5192
5189
  if (reconciled + appended > 0) {
5193
5190
  this.emit("folderCountsChanged", accountId, {});
5194
5191
  console.log(` [sent-sweep] ${accountId}: ${reconciled} rebound, ${appended} re-appended`);
@@ -5469,13 +5466,13 @@ export class ImapManager extends EventEmitter {
5469
5466
  this.stopPeriodicSync();
5470
5467
  this.stopOutboxWorker();
5471
5468
  await this.stopWatching();
5472
- // Disconnect persistent connections on both lanes. Use a Set
5473
- // because fastClients can hold an entry an account doesn't have
5474
- // in opsClients (e.g. body fetches happened but no sync did).
5475
- const accountIds = new Set<string>([
5476
- ...this.opsClients.keys(),
5477
- ...this.fastClients.keys(),
5478
- ]);
5469
+ // Disconnect persistent connections on every lane. Union across all
5470
+ // lane maps because a lane can hold an account the others don't (e.g.
5471
+ // body fetches happened on "fast" but no sync ran on "sync").
5472
+ const accountIds = new Set<string>();
5473
+ for (const map of this.laneClients.values()) {
5474
+ for (const k of map.keys()) accountIds.add(k);
5475
+ }
5479
5476
  for (const accountId of accountIds) {
5480
5477
  await this.disconnectOps(accountId);
5481
5478
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@bobfrankston/mailx-imap",
3
- "version": "0.1.104",
3
+ "version": "0.1.105",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@bobfrankston/mailx-imap",
9
- "version": "0.1.104",
9
+ "version": "0.1.105",
10
10
  "license": "ISC",
11
11
  "dependencies": {
12
12
  "@bobfrankston/iflow-direct": "^0.1.27",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/mailx-imap",
3
- "version": "0.1.104",
3
+ "version": "0.1.105",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",