emailengine-app 2.63.0 → 2.63.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.
package/server.js CHANGED
@@ -616,6 +616,8 @@ let workerAssigned = new WeakMap(); // Map of worker -> Set of accounts
616
616
  let onlineWorkers = new WeakSet(); // Set of workers that are online
617
617
  let reassignmentTimer = null; // Timer for failsafe reassignment
618
618
  let reassignmentPending = false; // Flag to track if reassignment is pending
619
+ let assignRetryCount = 0; // Counter for safety-net retries in assignAccounts
620
+ const MAX_ASSIGN_RETRIES = 3; // Max consecutive safety-net retries before giving up
619
621
 
620
622
  // Worker management
621
623
  let imapInitialWorkersLoaded = false; // Have all initial IMAP workers started?
@@ -1578,6 +1580,11 @@ async function assignAccounts() {
1578
1580
  let totalAccounts = assigned.size + unassigned.size;
1579
1581
  let targetPerWorker = Math.ceil(totalAccounts / availableIMAPWorkers.size);
1580
1582
 
1583
+ // Collect accounts that fail assignment so we do not re-insert into
1584
+ // the Set we are iterating (re-insertion during for..of would cause
1585
+ // the same account to be visited again in the same pass).
1586
+ let failedAccounts = [];
1587
+
1581
1588
  // Assign each unassigned account
1582
1589
  for (let account of unassigned) {
1583
1590
  if (!availableIMAPWorkers.size) {
@@ -1636,7 +1643,14 @@ async function assignAccounts() {
1636
1643
  // Roll back -- account was never actually assigned
1637
1644
  workerAssigned.get(worker).delete(account);
1638
1645
  assigned.delete(account);
1639
- unassigned.add(account);
1646
+ // Revert load map so subsequent iterations see accurate counts
1647
+ if (!isReassignment) {
1648
+ workerLoadMap.set(worker, workerLoadMap.get(worker) - 1);
1649
+ sortedWorkers = Array.from(workerLoadMap.entries())
1650
+ .sort((a, b) => a[1] - b[1])
1651
+ .map(entry => entry[0]);
1652
+ }
1653
+ failedAccounts.push(account);
1640
1654
  logger.error({ msg: 'Failed to assign account to worker', account, threadId: worker.threadId, err });
1641
1655
  continue;
1642
1656
  }
@@ -1647,6 +1661,11 @@ async function assignAccounts() {
1647
1661
  }
1648
1662
  }
1649
1663
 
1664
+ // Re-add failed accounts after iteration completes
1665
+ for (let account of failedAccounts) {
1666
+ unassigned.add(account);
1667
+ }
1668
+
1650
1669
  // Log final distribution for monitoring
1651
1670
  let distribution = [];
1652
1671
  for (let worker of availableIMAPWorkers) {
@@ -1661,15 +1680,30 @@ async function assignAccounts() {
1661
1680
  } finally {
1662
1681
  assigning = false;
1663
1682
 
1664
- // Safety net: if accounts remain unassigned, schedule a retry
1683
+ // Safety net: if accounts remain unassigned, schedule a retry with backoff
1665
1684
  if (unassigned && unassigned.size > 0 && availableIMAPWorkers.size > 0 && !isClosing) {
1666
- logger.warn({
1667
- msg: 'Accounts remain unassigned after assignment pass, scheduling retry',
1668
- remaining: unassigned.size
1669
- });
1670
- setTimeout(() => {
1671
- assignAccounts().catch(err => logger.error({ msg: 'Retry assignment failed', err }));
1672
- }, 5000);
1685
+ assignRetryCount++;
1686
+ if (assignRetryCount <= MAX_ASSIGN_RETRIES) {
1687
+ let delay = 5000 * assignRetryCount;
1688
+ logger.warn({
1689
+ msg: 'Accounts remain unassigned after assignment pass, scheduling retry',
1690
+ remaining: unassigned.size,
1691
+ retry: assignRetryCount,
1692
+ maxRetries: MAX_ASSIGN_RETRIES,
1693
+ delayMs: delay
1694
+ });
1695
+ setTimeout(() => {
1696
+ assignAccounts().catch(err => logger.error({ msg: 'Retry assignment failed', err }));
1697
+ }, delay);
1698
+ } else {
1699
+ logger.error({
1700
+ msg: 'Max assignment retries reached, accounts remain unassigned',
1701
+ remaining: unassigned.size
1702
+ });
1703
+ assignRetryCount = 0;
1704
+ }
1705
+ } else {
1706
+ assignRetryCount = 0;
1673
1707
  }
1674
1708
  }
1675
1709
  }
@@ -1,6 +1,6 @@
1
1
  <!doctype html><html><head><meta charset="utf-8"><title>EmailEngine Licenses</title><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css" integrity="sha384-zCbKRCUGaJDkqS1kPbPd7TveP5iyJE0EjAuZQTgFLD2ylzuqKfdKlfG/eSrtxUkn" crossorigin="anonymous"></head><body>
2
2
  <div class="container-fluid">
3
- <h1>EmailEngine v2.62.2</h1><p>EmailEngine includes code from the following software packages:</p>
3
+ <h1>EmailEngine v2.63.1</h1><p>EmailEngine includes code from the following software packages:</p>
4
4
  <table class="table table-sm">
5
5
  <tr><thead class="thead-dark"><th>Package</th><th>Version</th><th>License</th><th>Publisher</th><th>Publisher's Email</th><th>Package URL</th></tr>
6
6
  <tbody>
@@ -146,7 +146,7 @@
146
146
  </tr>
147
147
  <tr>
148
148
  <td><a href="https://npmjs.com/package/@bull-board/api">@bull-board/api</a></td>
149
- <td>6.19.0</td>
149
+ <td>6.20.3</td>
150
150
  <td>MIT</td>
151
151
  <td>felixmosh</td>
152
152
  <td></td>
@@ -156,7 +156,7 @@
156
156
  </tr>
157
157
  <tr>
158
158
  <td><a href="https://npmjs.com/package/@bull-board/hapi">@bull-board/hapi</a></td>
159
- <td>6.19.0</td>
159
+ <td>6.20.3</td>
160
160
  <td>MIT</td>
161
161
  <td>felixmosh</td>
162
162
  <td></td>
@@ -166,7 +166,7 @@
166
166
  </tr>
167
167
  <tr>
168
168
  <td><a href="https://npmjs.com/package/@bull-board/ui">@bull-board/ui</a></td>
169
- <td>6.19.0</td>
169
+ <td>6.20.3</td>
170
170
  <td>MIT</td>
171
171
  <td>felixmosh</td>
172
172
  <td></td>
@@ -216,7 +216,7 @@
216
216
  </tr>
217
217
  <tr>
218
218
  <td><a href="https://npmjs.com/package/@csstools/css-syntax-patches-for-csstree">@csstools/css-syntax-patches-for-csstree</a></td>
219
- <td>1.0.27</td>
219
+ <td>1.0.29</td>
220
220
  <td>MIT-0</td>
221
221
  <td></td>
222
222
  <td></td>
@@ -276,7 +276,7 @@
276
276
  </tr>
277
277
  <tr>
278
278
  <td><a href="https://npmjs.com/package/@eslint/config-array">@eslint/config-array</a></td>
279
- <td>0.23.1</td>
279
+ <td>0.23.2</td>
280
280
  <td>Apache-2.0</td>
281
281
  <td>Nicholas C. Zakas</td>
282
282
  <td></td>
@@ -316,7 +316,7 @@
316
316
  </tr>
317
317
  <tr>
318
318
  <td><a href="https://npmjs.com/package/@eslint/object-schema">@eslint/object-schema</a></td>
319
- <td>3.0.1</td>
319
+ <td>3.0.2</td>
320
320
  <td>Apache-2.0</td>
321
321
  <td>Nicholas C. Zakas</td>
322
322
  <td></td>
@@ -506,7 +506,7 @@
506
506
  </tr>
507
507
  <tr>
508
508
  <td><a href="https://npmjs.com/package/@hapi/hapi">@hapi/hapi</a></td>
509
- <td>21.4.5</td>
509
+ <td>21.4.6</td>
510
510
  <td>BSD-3-Clause</td>
511
511
  <td></td>
512
512
  <td></td>
@@ -785,6 +785,16 @@
785
785
  </td
786
786
  </tr>
787
787
  <tr>
788
+ <td><a href="https://npmjs.com/package/@ioredis/commands">@ioredis/commands</a></td>
789
+ <td>1.5.1</td>
790
+ <td>MIT</td>
791
+ <td>Zihua Li</td>
792
+ <td>i@zihua.li</td>
793
+ <td>
794
+ <a href="https://github.com/ioredis/commands">github.com/ioredis/commands</a>
795
+ </td
796
+ </tr>
797
+ <tr>
788
798
  <td><a href="https://npmjs.com/package/@jsdevtools/ono">@jsdevtools/ono</a></td>
789
799
  <td>7.1.3</td>
790
800
  <td>MIT</td>
@@ -846,7 +856,7 @@
846
856
  </tr>
847
857
  <tr>
848
858
  <td><a href="https://npmjs.com/package/@opentelemetry/semantic-conventions">@opentelemetry/semantic-conventions</a></td>
849
- <td>1.39.0</td>
859
+ <td>1.40.0</td>
850
860
  <td>Apache-2.0</td>
851
861
  <td>OpenTelemetry Authors</td>
852
862
  <td></td>
@@ -1266,7 +1276,7 @@
1266
1276
  </tr>
1267
1277
  <tr>
1268
1278
  <td><a href="https://npmjs.com/package/acorn">acorn</a></td>
1269
- <td>8.15.0</td>
1279
+ <td>8.16.0</td>
1270
1280
  <td>MIT</td>
1271
1281
  <td></td>
1272
1282
  <td></td>
@@ -1286,7 +1296,7 @@
1286
1296
  </tr>
1287
1297
  <tr>
1288
1298
  <td><a href="https://npmjs.com/package/ajv">ajv</a></td>
1289
- <td>6.12.6</td>
1299
+ <td>6.14.0</td>
1290
1300
  <td>MIT</td>
1291
1301
  <td>Evgeny Poberezkin</td>
1292
1302
  <td></td>
@@ -1466,7 +1476,7 @@
1466
1476
  </tr>
1467
1477
  <tr>
1468
1478
  <td><a href="https://npmjs.com/package/balanced-match">balanced-match</a></td>
1469
- <td>4.0.3</td>
1479
+ <td>4.0.4</td>
1470
1480
  <td>MIT</td>
1471
1481
  <td></td>
1472
1482
  <td></td>
@@ -1576,7 +1586,7 @@
1576
1586
  </tr>
1577
1587
  <tr>
1578
1588
  <td><a href="https://npmjs.com/package/brace-expansion">brace-expansion</a></td>
1579
- <td>5.0.2</td>
1589
+ <td>5.0.4</td>
1580
1590
  <td>MIT</td>
1581
1591
  <td></td>
1582
1592
  <td></td>
@@ -1606,7 +1616,7 @@
1606
1616
  </tr>
1607
1617
  <tr>
1608
1618
  <td><a href="https://npmjs.com/package/bullmq">bullmq</a></td>
1609
- <td>5.69.3</td>
1619
+ <td>5.70.1</td>
1610
1620
  <td>MIT</td>
1611
1621
  <td>Taskforce.sh Inc.</td>
1612
1622
  <td></td>
@@ -2485,7 +2495,7 @@
2485
2495
  </tr>
2486
2496
  <tr>
2487
2497
  <td><a href="https://npmjs.com/package/eslint-scope">eslint-scope</a></td>
2488
- <td>9.1.0</td>
2498
+ <td>9.1.1</td>
2489
2499
  <td>BSD-2-Clause</td>
2490
2500
  <td></td>
2491
2501
  <td></td>
@@ -2505,7 +2515,7 @@
2505
2515
  </tr>
2506
2516
  <tr>
2507
2517
  <td><a href="https://npmjs.com/package/eslint-visitor-keys">eslint-visitor-keys</a></td>
2508
- <td>5.0.0</td>
2518
+ <td>5.0.1</td>
2509
2519
  <td>Apache-2.0</td>
2510
2520
  <td>Toru Nagashima</td>
2511
2521
  <td></td>
@@ -2515,7 +2525,7 @@
2515
2525
  </tr>
2516
2526
  <tr>
2517
2527
  <td><a href="https://npmjs.com/package/eslint">eslint</a></td>
2518
- <td>10.0.0</td>
2528
+ <td>10.0.2</td>
2519
2529
  <td>MIT</td>
2520
2530
  <td>Nicholas C. Zakas</td>
2521
2531
  <td>nicholas+npm@nczconsulting.com</td>
@@ -2535,7 +2545,7 @@
2535
2545
  </tr>
2536
2546
  <tr>
2537
2547
  <td><a href="https://npmjs.com/package/espree">espree</a></td>
2538
- <td>11.1.0</td>
2548
+ <td>11.1.1</td>
2539
2549
  <td>BSD-2-Clause</td>
2540
2550
  <td>Nicholas C. Zakas</td>
2541
2551
  <td>nicholas+npm@nczconsulting.com</td>
@@ -2745,7 +2755,7 @@
2745
2755
  </tr>
2746
2756
  <tr>
2747
2757
  <td><a href="https://npmjs.com/package/filelist">filelist</a></td>
2748
- <td>1.0.4</td>
2758
+ <td>1.0.6</td>
2749
2759
  <td>Apache-2.0</td>
2750
2760
  <td>Matthew Eernisse</td>
2751
2761
  <td>mde@fleegix.org</td>
@@ -2835,7 +2845,7 @@
2835
2845
  </tr>
2836
2846
  <tr>
2837
2847
  <td><a href="https://npmjs.com/package/flatted">flatted</a></td>
2838
- <td>3.3.3</td>
2848
+ <td>3.3.4</td>
2839
2849
  <td>ISC</td>
2840
2850
  <td>Andrea Giammarchi</td>
2841
2851
  <td></td>
@@ -3465,7 +3475,7 @@
3465
3475
  </tr>
3466
3476
  <tr>
3467
3477
  <td><a href="https://npmjs.com/package/imapflow">imapflow</a></td>
3468
- <td>1.2.10</td>
3478
+ <td>1.2.11</td>
3469
3479
  <td>MIT</td>
3470
3480
  <td>Postal Systems O&#xDC;</td>
3471
3481
  <td></td>
@@ -3534,8 +3544,18 @@
3534
3544
  </td
3535
3545
  </tr>
3536
3546
  <tr>
3547
+ <td><a href="https://npmjs.com/package/ioredfour">ioredfour</a></td>
3548
+ <td>1.4.0</td>
3549
+ <td>MIT</td>
3550
+ <td>Mixmax</td>
3551
+ <td>hello@mixmax.com</td>
3552
+ <td>
3553
+ <a href="https://github.com/nodemailer/ioredfour">github.com/nodemailer/ioredfour</a>
3554
+ </td
3555
+ </tr>
3556
+ <tr>
3537
3557
  <td><a href="https://npmjs.com/package/ioredis">ioredis</a></td>
3538
- <td>5.3.2</td>
3558
+ <td>5.10.0</td>
3539
3559
  <td>MIT</td>
3540
3560
  <td>Zihua Li</td>
3541
3561
  <td>i@zihua.li</td>
@@ -3545,7 +3565,7 @@
3545
3565
  </tr>
3546
3566
  <tr>
3547
3567
  <td><a href="https://npmjs.com/package/ioredis">ioredis</a></td>
3548
- <td>5.9.2</td>
3568
+ <td>5.3.2</td>
3549
3569
  <td>MIT</td>
3550
3570
  <td>Zihua Li</td>
3551
3571
  <td>i@zihua.li</td>
@@ -4285,7 +4305,7 @@
4285
4305
  </tr>
4286
4306
  <tr>
4287
4307
  <td><a href="https://npmjs.com/package/minimatch">minimatch</a></td>
4288
- <td>10.2.1</td>
4308
+ <td>10.2.4</td>
4289
4309
  <td>BlueOak-1.0.0</td>
4290
4310
  <td>Isaac Z. Schlueter</td>
4291
4311
  <td>i@izs.me</td>
@@ -4305,7 +4325,7 @@
4305
4325
  </tr>
4306
4326
  <tr>
4307
4327
  <td><a href="https://npmjs.com/package/minimatch">minimatch</a></td>
4308
- <td>3.1.2</td>
4328
+ <td>3.1.5</td>
4309
4329
  <td>ISC</td>
4310
4330
  <td>Isaac Z. Schlueter</td>
4311
4331
  <td>i@izs.me</td>
@@ -4315,7 +4335,7 @@
4315
4335
  </tr>
4316
4336
  <tr>
4317
4337
  <td><a href="https://npmjs.com/package/minimatch">minimatch</a></td>
4318
- <td>5.1.6</td>
4338
+ <td>5.1.9</td>
4319
4339
  <td>ISC</td>
4320
4340
  <td>Isaac Z. Schlueter</td>
4321
4341
  <td>i@izs.me</td>
@@ -5135,7 +5155,7 @@
5135
5155
  </tr>
5136
5156
  <tr>
5137
5157
  <td><a href="https://npmjs.com/package/pump">pump</a></td>
5138
- <td>3.0.3</td>
5158
+ <td>3.0.4</td>
5139
5159
  <td>MIT</td>
5140
5160
  <td>Mathias Buus Madsen</td>
5141
5161
  <td>mathiasbuus@gmail.com</td>
@@ -5415,7 +5435,7 @@
5415
5435
  </tr>
5416
5436
  <tr>
5417
5437
  <td><a href="https://npmjs.com/package/sax">sax</a></td>
5418
- <td>1.4.4</td>
5438
+ <td>1.5.0</td>
5419
5439
  <td>BlueOak-1.0.0</td>
5420
5440
  <td>Isaac Z. Schlueter</td>
5421
5441
  <td>i@izs.me</td>
@@ -5685,7 +5705,7 @@
5685
5705
  </tr>
5686
5706
  <tr>
5687
5707
  <td><a href="https://npmjs.com/package/spdx-license-ids">spdx-license-ids</a></td>
5688
- <td>3.0.22</td>
5708
+ <td>3.0.23</td>
5689
5709
  <td>CC0-1.0</td>
5690
5710
  <td>Shinnosuke Watanabe</td>
5691
5711
  <td></td>
@@ -5915,7 +5935,7 @@
5915
5935
  </tr>
5916
5936
  <tr>
5917
5937
  <td><a href="https://npmjs.com/package/swagger-ui-dist">swagger-ui-dist</a></td>
5918
- <td>5.31.1</td>
5938
+ <td>5.32.0</td>
5919
5939
  <td>Apache-2.0</td>
5920
5940
  <td></td>
5921
5941
  <td></td>
@@ -5995,7 +6015,7 @@
5995
6015
  </tr>
5996
6016
  <tr>
5997
6017
  <td><a href="https://npmjs.com/package/tldts-core">tldts-core</a></td>
5998
- <td>7.0.23</td>
6018
+ <td>7.0.24</td>
5999
6019
  <td>MIT</td>
6000
6020
  <td>R&#xE9;mi Berson</td>
6001
6021
  <td></td>
@@ -6005,7 +6025,7 @@
6005
6025
  </tr>
6006
6026
  <tr>
6007
6027
  <td><a href="https://npmjs.com/package/tldts">tldts</a></td>
6008
- <td>7.0.23</td>
6028
+ <td>7.0.24</td>
6009
6029
  <td>MIT</td>
6010
6030
  <td>R&#xE9;mi Berson</td>
6011
6031
  <td></td>
@@ -1,7 +1,7 @@
1
1
  msgid ""
2
2
  msgstr ""
3
3
  "Content-Type: text/plain; charset=ascii\n"
4
- "POT-Creation-Date: 2026-02-19 09:51+0000\n"
4
+ "POT-Creation-Date: 2026-03-03 13:39+0000\n"
5
5
 
6
6
  #: views/config/license.hbs:45
7
7
  msgid "%d day"
@@ -62,21 +62,45 @@ msgstr ""
62
62
  msgid "Enter your email address"
63
63
  msgstr ""
64
64
 
65
- #: views/accounts/register/imap-server.hbs:19
66
- msgid "IMAP"
65
+ #: views/accounts/register/imap.hbs:11
66
+ msgid "Your name"
67
67
  msgstr ""
68
68
 
69
- #: views/accounts/register/imap-server.hbs:22
70
- #: views/accounts/register/imap-server.hbs:114
71
- msgid "Username"
69
+ #: views/accounts/register/imap.hbs:17
70
+ msgid "Enter your full name"
72
71
  msgstr ""
73
72
 
73
+ #: views/accounts/register/imap.hbs:31
74
74
  #: views/accounts/register/imap-server.hbs:36
75
75
  #: views/accounts/register/imap-server.hbs:128
76
- #: views/accounts/register/imap.hbs:31
77
76
  msgid "Password"
78
77
  msgstr ""
79
78
 
79
+ #: views/accounts/register/imap.hbs:37
80
+ msgid "Enter your account password"
81
+ msgstr ""
82
+
83
+ #: views/accounts/register/imap.hbs:51
84
+ msgid "Continue"
85
+ msgstr ""
86
+
87
+ #: views/accounts/register/index.hbs:2
88
+ msgid "Choose your email account provider"
89
+ msgstr ""
90
+
91
+ #: views/accounts/register/index.hbs:15
92
+ msgid "Standard IMAP"
93
+ msgstr ""
94
+
95
+ #: views/accounts/register/imap-server.hbs:19
96
+ msgid "IMAP"
97
+ msgstr ""
98
+
99
+ #: views/accounts/register/imap-server.hbs:22
100
+ #: views/accounts/register/imap-server.hbs:114
101
+ msgid "Username"
102
+ msgstr ""
103
+
80
104
  #: views/accounts/register/imap-server.hbs:45
81
105
  #: views/accounts/register/imap-server.hbs:136
82
106
  msgid "Important"
@@ -183,30 +207,6 @@ msgstr ""
183
207
  msgid "Request failed."
184
208
  msgstr ""
185
209
 
186
- #: views/accounts/register/index.hbs:2
187
- msgid "Choose your email account provider"
188
- msgstr ""
189
-
190
- #: views/accounts/register/index.hbs:15
191
- msgid "Standard IMAP"
192
- msgstr ""
193
-
194
- #: views/accounts/register/imap.hbs:11
195
- msgid "Your name"
196
- msgstr ""
197
-
198
- #: views/accounts/register/imap.hbs:17
199
- msgid "Enter your full name"
200
- msgstr ""
201
-
202
- #: views/accounts/register/imap.hbs:37
203
- msgid "Enter your account password"
204
- msgstr ""
205
-
206
- #: views/accounts/register/imap.hbs:51
207
- msgid "Continue"
208
- msgstr ""
209
-
210
210
  #: lib/routes-ui.js:523
211
211
  #: lib/ui-routes/account-routes.js:60
212
212
  msgid "Delegated"
@@ -253,7 +253,7 @@ msgstr ""
253
253
  #: lib/routes-ui.js:4874
254
254
  #: lib/routes-ui.js:5121
255
255
  #: lib/routes-ui.js:5157
256
- #: workers/api.js:2414
256
+ #: workers/api.js:2416
257
257
  #: lib/ui-routes/account-routes.js:549
258
258
  #: lib/ui-routes/account-routes.js:585
259
259
  #: lib/ui-routes/account-routes.js:702
@@ -327,7 +327,7 @@ msgid "Unexpected server response"
327
327
  msgstr ""
328
328
 
329
329
  #: lib/routes-ui.js:7693
330
- #: lib/tools.js:942
330
+ #: lib/tools.js:950
331
331
  msgid "Invalid input"
332
332
  msgstr ""
333
333
 
@@ -338,21 +338,21 @@ msgstr ""
338
338
  msgid "Subscription Management"
339
339
  msgstr ""
340
340
 
341
- #: workers/api.js:6908
342
- #: workers/api.js:7024
341
+ #: workers/api.js:6910
342
+ #: workers/api.js:7026
343
343
  msgid "Requested page not found"
344
344
  msgstr ""
345
345
 
346
- #: workers/api.js:6909
346
+ #: workers/api.js:6911
347
347
  msgid "Something went wrong"
348
348
  msgstr ""
349
349
 
350
- #: lib/tools.js:1645
350
+ #: lib/tools.js:1653
351
351
  msgid "Signature validation failed"
352
352
  msgstr ""
353
353
 
354
- #: lib/tools.js:1654
355
- #: lib/tools.js:1659
354
+ #: lib/tools.js:1662
355
+ #: lib/tools.js:1667
356
356
  msgid "Invalid or expired account setup URL"
357
357
  msgstr ""
358
358
 
package/workers/api.js CHANGED
@@ -40,7 +40,8 @@ const {
40
40
  getBoolean,
41
41
  loadTlsConfig,
42
42
  httpAgent,
43
- reloadHttpProxyAgent
43
+ reloadHttpProxyAgent,
44
+ resolveOAuthErrorStatus
44
45
  } = require('../lib/tools');
45
46
  const { matchIp, detectAutomatedRequest } = require('../lib/utils/network');
46
47
 
@@ -1491,17 +1492,55 @@ Include your token in requests using one of these methods:
1491
1492
  }
1492
1493
  });
1493
1494
 
1495
+ const staticRoot = pathlib.resolve(__dirname, '..', 'static');
1496
+ const staticRootPrefix = staticRoot + pathlib.sep;
1497
+
1494
1498
  server.route({
1495
1499
  method: 'GET',
1496
1500
  path: '/static/{file*}',
1497
1501
  handler: {
1498
1502
  directory: {
1499
- path: pathlib.join(__dirname, '..', 'static')
1503
+ path: staticRoot,
1504
+ index: false
1500
1505
  }
1501
1506
  },
1502
1507
  options: {
1503
1508
  auth: false,
1504
- tags: ['static']
1509
+ tags: ['static'],
1510
+ // Prevent EISDIR crash in pkg snapshot environments.
1511
+ // Inert calls fs.open() on directory paths which triggers an uncaught exception
1512
+ // in pkg's patched fs, so we intercept directory requests before they reach Inert.
1513
+ pre: process.pkg
1514
+ ? [
1515
+ {
1516
+ method: async request => {
1517
+ const filePath = request.params.file;
1518
+ if (!filePath) {
1519
+ throw Boom.notFound();
1520
+ }
1521
+
1522
+ const resolved = pathlib.resolve(staticRoot, filePath);
1523
+ if (!resolved.startsWith(staticRootPrefix)) {
1524
+ throw Boom.notFound();
1525
+ }
1526
+
1527
+ try {
1528
+ const stat = await fs.promises.stat(resolved);
1529
+ if (stat.isDirectory()) {
1530
+ throw Boom.notFound();
1531
+ }
1532
+ } catch (err) {
1533
+ if (err.isBoom) {
1534
+ throw err;
1535
+ }
1536
+ // stat failed (ENOENT etc.) - let Inert handle it
1537
+ }
1538
+
1539
+ return null;
1540
+ }
1541
+ }
1542
+ ]
1543
+ : undefined
1505
1544
  }
1506
1545
  });
1507
1546
 
@@ -2145,7 +2184,7 @@ Include your token in requests using one of these methods:
2145
2184
  message = response.error.message;
2146
2185
  }
2147
2186
 
2148
- let error = Boom.boomify(new Error(message), { statusCode: response.error.code });
2187
+ let error = Boom.boomify(new Error(message), { statusCode: resolveOAuthErrorStatus(response.error, err) });
2149
2188
  throw error;
2150
2189
  }
2151
2190
  throw err;
@@ -2239,7 +2278,7 @@ Include your token in requests using one of these methods:
2239
2278
  let response = err.oauthRequest && err.oauthRequest.response;
2240
2279
  if (response && response.error) {
2241
2280
  let message = response.error.message;
2242
- let error = Boom.boomify(new Error(message), { statusCode: response.error.code });
2281
+ let error = Boom.boomify(new Error(message), { statusCode: resolveOAuthErrorStatus(response.error, err) });
2243
2282
  throw error;
2244
2283
  }
2245
2284
  throw err;
@@ -2328,7 +2367,7 @@ Include your token in requests using one of these methods:
2328
2367
  let response = err.oauthRequest && err.oauthRequest.response;
2329
2368
  if (response && response.error) {
2330
2369
  let message = response.error.message;
2331
- let error = Boom.boomify(new Error(message), { statusCode: response.error.code });
2370
+ let error = Boom.boomify(new Error(message), { statusCode: resolveOAuthErrorStatus(response.error, err) });
2332
2371
  throw error;
2333
2372
  }
2334
2373
  throw err;