emailengine-app 2.62.0 → 2.62.2

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.
@@ -241,7 +241,7 @@ const documentsWorker = new Worker(
241
241
  return;
242
242
  }
243
243
 
244
- let deleteResult = null;
244
+ let deleteResult;
245
245
 
246
246
  let filterQuery = {
247
247
  bool: {
@@ -612,7 +612,7 @@ const documentsWorker = new Worker(
612
612
  return;
613
613
  }
614
614
 
615
- let deleteResult = null;
615
+ let deleteResult;
616
616
 
617
617
  try {
618
618
  let messageIdHeader;
package/workers/export.js CHANGED
@@ -17,7 +17,7 @@ const {
17
17
  DEFAULT_EXPORT_MAX_MESSAGES,
18
18
  DEFAULT_EXPORT_MAX_SIZE
19
19
  } = require('../lib/consts');
20
- const { getDuration, readEnvValue, threadStats } = require('../lib/tools');
20
+ const { getDuration, readEnvValue, threadStats, reloadHttpProxyAgent } = require('../lib/tools');
21
21
  const { webhooks: Webhooks } = require('../lib/webhooks');
22
22
  const settings = require('../lib/settings');
23
23
  const { Export } = require('../lib/export');
@@ -182,7 +182,7 @@ async function indexMessages(job, exportData) {
182
182
  try {
183
183
  mailboxes = await accountObject.listMailboxes();
184
184
  } catch (err) {
185
- throw new Error(`Failed to list mailboxes: ${err.message}`);
185
+ throw new Error(`Failed to list mailboxes: ${err.message}`, { cause: err });
186
186
  }
187
187
 
188
188
  const foldersToProcess = resolveFolders(folders, mailboxes);
@@ -913,6 +913,13 @@ parentPort.on('message', message => {
913
913
  .then(response => parentPort.postMessage({ cmd: 'resp', mid: message.mid, response }))
914
914
  .catch(err => parentPort.postMessage({ cmd: 'resp', mid: message.mid, error: err.message, code: err.code, statusCode: err.statusCode }));
915
915
  }
916
+
917
+ if (message && message.cmd === 'settings') {
918
+ let d = message.data || {};
919
+ if ('httpProxyEnabled' in d || 'httpProxyUrl' in d) {
920
+ reloadHttpProxyAgent().catch(err => logger.error({ msg: 'Failed to reload HTTP proxy agent', err }));
921
+ }
922
+ }
916
923
  });
917
924
 
918
925
  logger.info({ msg: 'Started export worker thread', version: packageData.version });
package/workers/imap.js CHANGED
@@ -7,7 +7,7 @@ const logger = require('../lib/logger');
7
7
 
8
8
  const { REDIS_PREFIX } = require('../lib/consts');
9
9
 
10
- const { getDuration, getBoolean, emitChangeEvent, readEnvValue, hasEnvValue, threadStats } = require('../lib/tools');
10
+ const { getDuration, getBoolean, emitChangeEvent, readEnvValue, hasEnvValue, threadStats, reloadHttpProxyAgent } = require('../lib/tools');
11
11
 
12
12
  const Bugsnag = require('@bugsnag/js');
13
13
  if (readEnvValue('BUGSNAG_API_KEY')) {
@@ -826,6 +826,10 @@ class ConnectionHandler {
826
826
 
827
827
  switch (message.cmd) {
828
828
  case 'settings':
829
+ if (message.data && ('httpProxyEnabled' in message.data || 'httpProxyUrl' in message.data)) {
830
+ reloadHttpProxyAgent().catch(err => logger.error({ msg: 'Failed to reload HTTP proxy agent', err }));
831
+ }
832
+
829
833
  if (message.data && message.data.logs) {
830
834
  for (let [account, accountObject] of this.accounts) {
831
835
  // update log handling
package/workers/submit.js CHANGED
@@ -7,7 +7,7 @@ const config = require('@zone-eu/wild-config');
7
7
  const logger = require('../lib/logger');
8
8
 
9
9
  const { REDIS_PREFIX } = require('../lib/consts');
10
- const { getDuration, readEnvValue, threadStats } = require('../lib/tools');
10
+ const { getDuration, readEnvValue, threadStats, reloadHttpProxyAgent } = require('../lib/tools');
11
11
  const { webhooks: Webhooks } = require('../lib/webhooks');
12
12
  const settings = require('../lib/settings');
13
13
 
@@ -494,6 +494,13 @@ parentPort.on('message', message => {
494
494
  });
495
495
  });
496
496
  }
497
+
498
+ if (message && message.cmd === 'settings') {
499
+ let d = message.data || {};
500
+ if ('httpProxyEnabled' in d || 'httpProxyUrl' in d) {
501
+ reloadHttpProxyAgent().catch(err => logger.error({ msg: 'Failed to reload HTTP proxy agent', err }));
502
+ }
503
+ }
497
504
  });
498
505
 
499
506
  logger.info({ msg: 'Started SMTP submission worker thread', version: packageData.version });
@@ -10,7 +10,7 @@ const { webhooks: Webhooks } = require('../lib/webhooks');
10
10
 
11
11
  const { GooglePubSub } = require('../lib/oauth/pubsub/google');
12
12
 
13
- const { readEnvValue, threadStats, getDuration, retryAgent, getServiceSecret } = require('../lib/tools');
13
+ const { readEnvValue, threadStats, getDuration, httpAgent, getServiceSecret, reloadHttpProxyAgent } = require('../lib/tools');
14
14
 
15
15
  const Bugsnag = require('@bugsnag/js');
16
16
  if (readEnvValue('BUGSNAG_API_KEY')) {
@@ -176,6 +176,13 @@ parentPort.on('message', message => {
176
176
  });
177
177
  });
178
178
  }
179
+
180
+ if (message && message.cmd === 'settings') {
181
+ let d = message.data || {};
182
+ if ('httpProxyEnabled' in d || 'httpProxyUrl' in d) {
183
+ reloadHttpProxyAgent().catch(err => logger.error({ msg: 'Failed to reload HTTP proxy agent', err }));
184
+ }
185
+ }
179
186
  });
180
187
 
181
188
  const notifyWorker = new Worker(
@@ -402,7 +409,7 @@ const notifyWorker = new Worker(
402
409
  method: 'post',
403
410
  body,
404
411
  headers,
405
- dispatcher: retryAgent
412
+ dispatcher: httpAgent.retry
406
413
  });
407
414
  duration = Date.now() - start;
408
415
  } catch (err) {