imapflow 1.0.156 → 1.0.157

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,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.0.157](https://github.com/postalsys/imapflow/compare/v1.0.156...v1.0.157) (2024-03-19)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **logs:** Log mailbox lock description ([ce87cf5](https://github.com/postalsys/imapflow/commit/ce87cf5a256ddc324624893a1c17992475fafeb3))
9
+
3
10
  ## [1.0.156](https://github.com/postalsys/imapflow/compare/v1.0.155...v1.0.156) (2024-03-07)
4
11
 
5
12
 
package/lib/imap-flow.js CHANGED
@@ -1313,7 +1313,7 @@ class ImapFlow extends EventEmitter {
1313
1313
 
1314
1314
  await new Promise((resolve, reject) => {
1315
1315
  this.connectTimeout = setTimeout(() => {
1316
- let err = new Error('Failed to established connection in required time');
1316
+ let err = new Error('Failed to establish connection in required time');
1317
1317
  err.code = 'CONNECT_TIMEOUT';
1318
1318
  err.details = {
1319
1319
  connectionTimeout: this.options.connectionTimeout || CONNECT_TIMEOUT
@@ -2840,17 +2840,35 @@ class ImapFlow extends EventEmitter {
2840
2840
 
2841
2841
  async processLocks(force) {
2842
2842
  if (!force && this.processingLock) {
2843
+ this.log.trace({
2844
+ msg: 'Mailbox locking queued',
2845
+ path: this.mailbox && this.mailbox.path,
2846
+ pending: this.locks.length,
2847
+ idling: this.idling
2848
+ });
2843
2849
  return;
2844
2850
  }
2851
+
2845
2852
  if (!this.locks.length) {
2846
2853
  this.processingLock = false;
2854
+ this.log.trace({
2855
+ msg: 'Mailbox locking queue processed',
2856
+ idling: this.idling
2857
+ });
2847
2858
  return;
2848
2859
  }
2860
+
2849
2861
  this.processingLock = true;
2850
2862
 
2851
2863
  const release = () => {
2852
2864
  if (this.currentLockId) {
2853
- this.log.trace({ msg: 'Mailbox lock released', lockId: this.currentLockId, path: this.mailbox && this.mailbox.path });
2865
+ this.log.trace({
2866
+ msg: 'Mailbox lock released',
2867
+ lockId: this.currentLockId,
2868
+ path: this.mailbox && this.mailbox.path,
2869
+ pending: this.locks.length,
2870
+ idling: this.idling
2871
+ });
2854
2872
  this.currentLockId = 0;
2855
2873
  }
2856
2874
  this.processLocks(true).catch(err => this.log.error({ err, cid: this.id }));
@@ -2859,7 +2877,7 @@ class ImapFlow extends EventEmitter {
2859
2877
  const { resolve, reject, path, options, lockId } = this.locks.shift();
2860
2878
 
2861
2879
  if (!this.usable || this.socket.destroyed) {
2862
- this.log.trace({ msg: 'Failed to acquire mailbox lock', path, lockId });
2880
+ this.log.trace({ msg: 'Failed to acquire mailbox lock', path, lockId, idling: this.idling });
2863
2881
  // reject all
2864
2882
  let error = new Error('Connection not available');
2865
2883
  error.code = 'NoConnection';
@@ -2869,14 +2887,14 @@ class ImapFlow extends EventEmitter {
2869
2887
 
2870
2888
  if (this.mailbox && this.mailbox.path === path && !!this.mailbox.readOnly === !!options.readOnly) {
2871
2889
  // nothing to do here, already selected
2872
- this.log.trace({ msg: 'Mailbox lock acquired', path, lockId });
2890
+ this.log.trace({ msg: 'Mailbox lock acquired', path, lockId, idling: this.idling });
2873
2891
  this.currentLockId = lockId;
2874
2892
  return resolve({ path, release });
2875
2893
  } else {
2876
2894
  try {
2877
2895
  // Try to open. Throws if mailbox does not exists or can't open
2878
2896
  await this.mailboxOpen(path, options);
2879
- this.log.trace({ msg: 'Lock acquired', path, lockId });
2897
+ this.log.trace({ msg: 'Lock acquired', path, lockId, idling: this.idling, ...(options.description && { description: options.description }) });
2880
2898
  this.currentLockId = lockId;
2881
2899
  return resolve({ path, release });
2882
2900
  } catch (err) {
@@ -2891,7 +2909,7 @@ class ImapFlow extends EventEmitter {
2891
2909
  }
2892
2910
  }
2893
2911
 
2894
- this.log.trace({ msg: 'Failed to acquire mailbox lock', path, lockId });
2912
+ this.log.trace({ msg: 'Failed to acquire mailbox lock', path, lockId, idling: this.idling });
2895
2913
  reject(err);
2896
2914
  await this.processLocks(true);
2897
2915
  }
@@ -2925,7 +2943,7 @@ class ImapFlow extends EventEmitter {
2925
2943
  path = normalizePath(this, path);
2926
2944
 
2927
2945
  let lockId = ++this.lockCounter;
2928
- this.log.trace({ msg: 'Requesting lock', path, lockId });
2946
+ this.log.trace({ msg: 'Requesting lock', path, lockId, ...(options.description && { description: options.description }) });
2929
2947
 
2930
2948
  return await new Promise((resolve, reject) => {
2931
2949
  this.locks.push({ resolve, reject, path, options, lockId });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imapflow",
3
- "version": "1.0.156",
3
+ "version": "1.0.157",
4
4
  "description": "IMAP Client for Node",
5
5
  "main": "./lib/imap-flow.js",
6
6
  "scripts": {
@@ -32,7 +32,7 @@
32
32
  "@babel/eslint-plugin": "7.23.5",
33
33
  "@babel/plugin-syntax-class-properties": "7.12.13",
34
34
  "@babel/preset-env": "7.24.0",
35
- "@types/node": "20.11.24",
35
+ "@types/node": "20.11.29",
36
36
  "eslint": "8.57.0",
37
37
  "eslint-config-nodemailer": "1.2.0",
38
38
  "eslint-config-prettier": "9.1.0",
@@ -52,7 +52,7 @@
52
52
  "libmime": "5.3.4",
53
53
  "libqp": "2.1.0",
54
54
  "mailsplit": "5.4.0",
55
- "nodemailer": "6.9.11",
55
+ "nodemailer": "6.9.12",
56
56
  "pino": "8.19.0",
57
57
  "socks": "2.8.1"
58
58
  }