imapflow 1.0.152 → 1.0.154

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
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.0.154](https://github.com/postalsys/imapflow/compare/v1.0.153...v1.0.154) (2024-03-05)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **FETCH:** throw on failing FETCH ([12f9a45](https://github.com/postalsys/imapflow/commit/12f9a45530c6f3a2f35ba2968819011eea9c32b2))
9
+
10
+ ## [1.0.153](https://github.com/postalsys/imapflow/compare/v1.0.152...v1.0.153) (2024-02-29)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * **deps:** Bumped deps ([559aa72](https://github.com/postalsys/imapflow/commit/559aa72337018f21a3675f4521ce4aae87e0aabb))
16
+
3
17
  ## [1.0.152](https://github.com/postalsys/imapflow/compare/v1.0.151...v1.0.152) (2024-02-12)
4
18
 
5
19
 
@@ -203,7 +203,7 @@ module.exports = async (connection, range, query, options) => {
203
203
  }
204
204
 
205
205
  connection.log.warn({ err, cid: connection.id });
206
- return false;
206
+ throw err;
207
207
  }
208
208
  }
209
209
  };
package/lib/imap-flow.js CHANGED
@@ -2254,93 +2254,94 @@ class ImapFlow extends EventEmitter {
2254
2254
  */
2255
2255
  async *fetch(range, query, options) {
2256
2256
  options = options || {};
2257
- try {
2258
- if (!this.mailbox) {
2259
- // no mailbox selected, nothing to do
2260
- return;
2261
- }
2262
2257
 
2263
- range = await this.resolveRange(range, options);
2264
- if (!range) {
2265
- return false;
2266
- }
2258
+ if (!this.mailbox) {
2259
+ // no mailbox selected, nothing to do
2260
+ return;
2261
+ }
2267
2262
 
2268
- let finished = false;
2269
- let push = false;
2270
- let rowQueue = [];
2271
- let getNext = () =>
2272
- new Promise((resolve, reject) => {
2273
- let check = () => {
2274
- if (rowQueue.length) {
2275
- let entry = rowQueue.shift();
2276
- if (entry.err) {
2277
- return reject(entry.err);
2278
- } else {
2279
- return resolve(entry.value);
2280
- }
2281
- }
2282
- if (finished) {
2283
- return resolve(null);
2284
- }
2263
+ range = await this.resolveRange(range, options);
2264
+ if (!range) {
2265
+ return false;
2266
+ }
2285
2267
 
2286
- // wait until data is pushed to queue and try again
2287
- push = () => {
2288
- push = false;
2289
- check();
2290
- };
2291
- };
2292
- check();
2293
- });
2268
+ let finished = false;
2269
+ let push = false;
2270
+ let rowQueue = [];
2294
2271
 
2295
- this.run('FETCH', range, query, {
2296
- uid: !!options.uid,
2297
- binary: options.binary,
2298
- changedSince: options.changedSince,
2299
- onUntaggedFetch: (untagged, next) => {
2300
- rowQueue.push({
2301
- value: {
2302
- response: untagged,
2303
- next
2272
+ let getNext = () =>
2273
+ new Promise((resolve, reject) => {
2274
+ let check = () => {
2275
+ if (rowQueue.length) {
2276
+ let entry = rowQueue.shift();
2277
+ if (entry.err) {
2278
+ return reject(entry.err);
2279
+ } else {
2280
+ return resolve(entry.value);
2304
2281
  }
2305
- });
2306
- if (typeof push === 'function') {
2307
- push();
2308
2282
  }
2309
- }
2310
- })
2311
- .then(() => {
2312
- finished = true;
2313
- if (typeof push === 'function') {
2314
- push();
2283
+
2284
+ if (finished) {
2285
+ return resolve(null);
2315
2286
  }
2316
- })
2317
- .catch(err => {
2318
- rowQueue.push({ err });
2319
- });
2320
2287
 
2321
- let res;
2322
- while ((res = await getNext())) {
2323
- if (this.isClosed || this.socket.destroyed) {
2324
- let error = new Error('Connection closed');
2325
- error.code = 'EConnectionClosed';
2326
- throw error;
2327
- }
2288
+ // wait until data is pushed to queue and try again
2289
+ push = () => {
2290
+ push = false;
2291
+ check();
2292
+ };
2293
+ };
2294
+ check();
2295
+ });
2328
2296
 
2329
- if (res !== null) {
2330
- yield res.response;
2331
- res.next();
2297
+ this.run('FETCH', range, query, {
2298
+ uid: !!options.uid,
2299
+ binary: options.binary,
2300
+ changedSince: options.changedSince,
2301
+ onUntaggedFetch: (untagged, next) => {
2302
+ rowQueue.push({
2303
+ value: {
2304
+ response: untagged,
2305
+ next
2306
+ }
2307
+ });
2308
+ if (typeof push === 'function') {
2309
+ push();
2332
2310
  }
2333
2311
  }
2312
+ })
2313
+ .then(() => {
2314
+ finished = true;
2315
+ if (typeof push === 'function') {
2316
+ push();
2317
+ }
2318
+ })
2319
+ .catch(err => {
2320
+ rowQueue.push({ err });
2321
+ if (typeof push === 'function') {
2322
+ push();
2323
+ }
2324
+ });
2334
2325
 
2335
- if (!finished) {
2336
- // FETCH never finished!
2337
- let error = new Error('FETCH did not finish');
2338
- error.code = 'ENotFinished';
2326
+ let res;
2327
+ while ((res = await getNext())) {
2328
+ if (this.isClosed || this.socket.destroyed) {
2329
+ let error = new Error('Connection closed');
2330
+ error.code = 'EConnectionClosed';
2339
2331
  throw error;
2340
2332
  }
2341
- } catch (err) {
2342
- setImmediate(() => this.close());
2343
- throw err;
2333
+
2334
+ if (res !== null) {
2335
+ yield res.response;
2336
+ res.next();
2337
+ }
2338
+ }
2339
+
2340
+ if (!finished) {
2341
+ // FETCH never finished!
2342
+ let error = new Error('FETCH did not finish');
2343
+ error.code = 'ENotFinished';
2344
+ throw error;
2344
2345
  }
2345
2346
  }
2346
2347
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imapflow",
3
- "version": "1.0.152",
3
+ "version": "1.0.154",
4
4
  "description": "IMAP Client for Node",
5
5
  "main": "./lib/imap-flow.js",
6
6
  "scripts": {
@@ -31,9 +31,9 @@
31
31
  "@babel/eslint-parser": "7.23.10",
32
32
  "@babel/eslint-plugin": "7.23.5",
33
33
  "@babel/plugin-syntax-class-properties": "7.12.13",
34
- "@babel/preset-env": "7.23.9",
35
- "@types/node": "20.11.17",
36
- "eslint": "8.56.0",
34
+ "@babel/preset-env": "7.24.0",
35
+ "@types/node": "20.11.24",
36
+ "eslint": "8.57.0",
37
37
  "eslint-config-nodemailer": "1.2.0",
38
38
  "eslint-config-prettier": "9.1.0",
39
39
  "grunt": "1.6.1",
@@ -48,12 +48,12 @@
48
48
  "dependencies": {
49
49
  "encoding-japanese": "2.0.0",
50
50
  "iconv-lite": "0.6.3",
51
- "libbase64": "1.2.1",
52
- "libmime": "5.2.1",
53
- "libqp": "2.0.1",
51
+ "libbase64": "1.3.0",
52
+ "libmime": "5.3.4",
53
+ "libqp": "2.1.0",
54
54
  "mailsplit": "5.4.0",
55
- "nodemailer": "6.9.9",
56
- "pino": "8.18.0",
57
- "socks": "2.7.3"
55
+ "nodemailer": "6.9.11",
56
+ "pino": "8.19.0",
57
+ "socks": "2.8.1"
58
58
  }
59
59
  }