@bobfrankston/iflow-direct 0.1.50 → 0.1.51

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/imap-native.js +33 -2
  2. package/package.json +1 -1
package/imap-native.js CHANGED
@@ -132,8 +132,29 @@ export class NativeImapClient {
132
132
  }
133
133
  });
134
134
  this.transport.onError((err) => {
135
+ // Diagnose transport-level errors fully. Node emits socket errors
136
+ // with a populated `.message` in normal cases (ECONNRESET, ETIMEDOUT,
137
+ // etc.) — but TLS-layer errors, abrupt FINs surfaced as errors,
138
+ // and some wrapper paths produce an Error with empty `.message`
139
+ // and the useful info on `.code` / `.errno` / `.syscall` instead.
140
+ // Logging only `.message` left "Transport error: " in the log
141
+ // with no diagnostic content, which masked why bobma INBOX prefetch
142
+ // kept dying (2026-05-27). Build a richer description.
143
+ const errAny = err;
144
+ const parts = [];
145
+ if (errAny?.message)
146
+ parts.push(String(errAny.message));
147
+ if (errAny?.code)
148
+ parts.push(`code=${errAny.code}`);
149
+ if (errAny?.errno !== undefined)
150
+ parts.push(`errno=${errAny.errno}`);
151
+ if (errAny?.syscall)
152
+ parts.push(`syscall=${errAny.syscall}`);
153
+ const desc = parts.length > 0
154
+ ? parts.join(" ")
155
+ : `<no message> ${typeof err} ${err?.constructor?.name || ""}`.trim();
135
156
  if (this.verbose)
136
- console.error(` [imap] Transport error: ${err.message}`);
157
+ console.error(` [imap] Transport error: ${desc}`);
137
158
  // Transport errors (DNS failure, ECONNRESET, TLS failure, etc.) mean
138
159
  // the connection is dead — clear the flag so ensureConnected() will
139
160
  // reconnect on the next call, and drop the stale IDLE state so we
@@ -149,7 +170,17 @@ export class NativeImapClient {
149
170
  if (this.pendingCommand) {
150
171
  const { reject } = this.pendingCommand;
151
172
  this.pendingCommand = null;
152
- reject(err);
173
+ // Make sure the error that propagates to upper-layer catches
174
+ // (prefetch, sync, etc.) has a non-empty message — wrap if
175
+ // the underlying err has a blank message.
176
+ if (err instanceof Error && !err.message) {
177
+ const wrapped = new Error(desc);
178
+ wrapped.cause = err;
179
+ reject(wrapped);
180
+ }
181
+ else {
182
+ reject(err);
183
+ }
153
184
  }
154
185
  });
155
186
  await this.transport.connect(this.config.server, this.config.port, useTls, this.config.server);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/iflow-direct",
3
- "version": "0.1.50",
3
+ "version": "0.1.51",
4
4
  "description": "Direct IMAP client — transport-agnostic, no Node.js dependencies, browser-ready",
5
5
  "main": "index.js",
6
6
  "types": "index.ts",