Skip to content

Commit c3f5ac7

Browse files
committed
fix(config): Properly parse time values from EENGINE_MAX_PAYLOAD_TIMEOUT config option
1 parent 4c09f8a commit c3f5ac7

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

lib/tools.js

+4
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,10 @@ module.exports = {
436436
},
437437

438438
getByteSize(val) {
439+
if (typeof val === 'number') {
440+
return val;
441+
}
442+
439443
val = (val || '').toString().replace(/^([\d.]+)\s*([kMGTP])B?$/i, (o, num, m) => {
440444
if (!num || isNaN(num)) {
441445
return false;

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"bull-arena": "4.2.0",
6262
"bullmq": "5.2.1",
6363
"compare-versions": "6.1.0",
64-
"dotenv": "16.4.4",
64+
"dotenv": "16.4.5",
6565
"encoding-japanese": "2.0.0",
6666
"exponential-backoff": "3.1.1",
6767
"express": "4.18.2",

server.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -2211,6 +2211,11 @@ const startApplication = async () => {
22112211
await settings.set('cookiePassword', cookiePassword);
22122212
}
22132213

2214+
// -- START WORKER THREADS
2215+
2216+
// single worker for HTTP, start first for health checks
2217+
await spawnWorker('api');
2218+
22142219
// multiple IMAP connection handlers
22152220
let workerPromises = [];
22162221
for (let i = 0; i < config.workers.imap; i++) {
@@ -2246,9 +2251,6 @@ const startApplication = async () => {
22462251
// single IMAP proxy interface worker
22472252
await spawnWorker('imapProxy');
22482253
}
2249-
2250-
// single worker for HTTP, start last to avoid running API requests for still-missing targets
2251-
await spawnWorker('api');
22522254
};
22532255

22542256
startApplication()

workers/api.js

+15-2
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ const IMAP_WORKER_COUNT = getWorkerCount(readEnvValue('EENGINE_WORKERS') || (con
204204
const MAX_BODY_SIZE = getByteSize(readEnvValue('EENGINE_MAX_BODY_SIZE') || config.api.maxBodySize) || DEFAULT_MAX_BODY_SIZE;
205205

206206
// Payload reception timeout in milliseconds for message upload requests
207-
const MAX_PAYLOAD_TIMEOUT = getByteSize(readEnvValue('EENGINE_MAX_PAYLOAD_TIMEOUT') || config.api.maxPayloadTimeout) || DEFAULT_MAX_PAYLOAD_TIMEOUT;
207+
const MAX_PAYLOAD_TIMEOUT = getDuration(readEnvValue('EENGINE_MAX_PAYLOAD_TIMEOUT') || config.api.maxPayloadTimeout) || DEFAULT_MAX_PAYLOAD_TIMEOUT;
208208

209209
// CORS configuration for API requests
210210
// By default, CORS is not enabled
@@ -234,7 +234,20 @@ const CORS_CONFIG = !CORS_ORIGINS
234234
credentials: true
235235
};
236236

237-
logger.debug({ msg: 'CORS config for API requests', cors: CORS_CONFIG });
237+
logger.info({
238+
msg: 'API server configuration',
239+
api: {
240+
port: API_PORT,
241+
host: API_HOST,
242+
maxPayloadTimeout: MAX_PAYLOAD_TIMEOUT,
243+
maxBodySize: MAX_BODY_SIZE,
244+
maxSize: MAX_ATTACHMENT_SIZE
245+
},
246+
service: {
247+
commandTimeout: EENGINE_TIMEOUT
248+
},
249+
cors: CORS_CONFIG
250+
});
238251

239252
const TRACKER_IMAGE = Buffer.from('R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7', 'base64');
240253

0 commit comments

Comments
 (0)