@budibase/backend-core 2.12.3 → 2.12.5

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/dist/index.js CHANGED
@@ -5607,6 +5607,8 @@ __export(src_exports, {
5607
5607
  DEFAULT_TENANT_ID: () => DEFAULT_TENANT_ID,
5608
5608
  DeprecatedViews: () => DeprecatedViews,
5609
5609
  DocumentType: () => DocumentType,
5610
+ Duration: () => Duration,
5611
+ DurationType: () => DurationType,
5610
5612
  EmailUnavailableError: () => EmailUnavailableError,
5611
5613
  ErrorCode: () => ErrorCode,
5612
5614
  FeatureDisabledError: () => FeatureDisabledError,
@@ -7324,6 +7326,8 @@ var import_events2 = __toESM(require("events"));
7324
7326
  // src/utils/index.ts
7325
7327
  var utils_exports3 = {};
7326
7328
  __export(utils_exports3, {
7329
+ Duration: () => Duration,
7330
+ DurationType: () => DurationType,
7327
7331
  clearCookie: () => clearCookie,
7328
7332
  compare: () => compare,
7329
7333
  getAppIdFromCtx: () => getAppIdFromCtx,
@@ -7508,6 +7512,51 @@ function validEmail(value) {
7508
7512
  );
7509
7513
  }
7510
7514
 
7515
+ // src/utils/Duration.ts
7516
+ var DurationType = /* @__PURE__ */ ((DurationType2) => {
7517
+ DurationType2["MILLISECONDS"] = "milliseconds";
7518
+ DurationType2["SECONDS"] = "seconds";
7519
+ DurationType2["MINUTES"] = "minutes";
7520
+ DurationType2["HOURS"] = "hours";
7521
+ DurationType2["DAYS"] = "days";
7522
+ return DurationType2;
7523
+ })(DurationType || {});
7524
+ var conversion = {
7525
+ milliseconds: 1,
7526
+ seconds: 1e3,
7527
+ minutes: 60 * 1e3,
7528
+ hours: 60 * 60 * 1e3,
7529
+ days: 24 * 60 * 60 * 1e3
7530
+ };
7531
+ var Duration = class _Duration {
7532
+ static convert(from, to, duration) {
7533
+ const milliseconds = duration * conversion[from];
7534
+ return milliseconds / conversion[to];
7535
+ }
7536
+ static from(from, duration) {
7537
+ return {
7538
+ to: (to) => {
7539
+ return _Duration.convert(from, to, duration);
7540
+ },
7541
+ toMs: () => {
7542
+ return _Duration.convert(from, "milliseconds" /* MILLISECONDS */, duration);
7543
+ }
7544
+ };
7545
+ }
7546
+ static fromSeconds(duration) {
7547
+ return _Duration.from("seconds" /* SECONDS */, duration);
7548
+ }
7549
+ static fromMinutes(duration) {
7550
+ return _Duration.from("minutes" /* MINUTES */, duration);
7551
+ }
7552
+ static fromHours(duration) {
7553
+ return _Duration.from("hours" /* HOURS */, duration);
7554
+ }
7555
+ static fromDays(duration) {
7556
+ return _Duration.from("days" /* DAYS */, duration);
7557
+ }
7558
+ };
7559
+
7511
7560
  // src/queue/inMemoryQueue.ts
7512
7561
  function newJob(queue, message) {
7513
7562
  return {
@@ -7523,7 +7572,7 @@ var InMemoryQueue = class {
7523
7572
  * @param opts This is not used by the in memory queue as there is no real use
7524
7573
  * case when in memory, but is the same API as Bull
7525
7574
  */
7526
- constructor(name, opts = null) {
7575
+ constructor(name, opts) {
7527
7576
  this._name = name;
7528
7577
  this._opts = opts;
7529
7578
  this._messages = [];
@@ -7745,7 +7794,9 @@ function logging(queue, jobQueue) {
7745
7794
 
7746
7795
  // src/queue/queue.ts
7747
7796
  init_timers2();
7748
- var CLEANUP_PERIOD_MS = 60 * 1e3;
7797
+ var QUEUE_LOCK_MS = Duration.fromMinutes(5).toMs();
7798
+ var QUEUE_LOCK_RENEW_INTERNAL_MS = Duration.fromSeconds(30).toMs();
7799
+ var CLEANUP_PERIOD_MS = Duration.fromSeconds(60).toMs();
7749
7800
  var QUEUES = [];
7750
7801
  var cleanupInterval;
7751
7802
  async function cleanup2() {
@@ -7755,7 +7806,14 @@ async function cleanup2() {
7755
7806
  }
7756
7807
  function createQueue(jobQueue, opts = {}) {
7757
7808
  const { opts: redisOpts, redisProtocolUrl } = getRedisOptions();
7758
- const queueConfig = redisProtocolUrl || { redis: redisOpts };
7809
+ const queueConfig = {
7810
+ redis: redisProtocolUrl || redisOpts,
7811
+ settings: {
7812
+ maxStalledCount: 0,
7813
+ lockDuration: QUEUE_LOCK_MS,
7814
+ lockRenewTime: QUEUE_LOCK_RENEW_INTERNAL_MS
7815
+ }
7816
+ };
7759
7817
  let queue;
7760
7818
  if (!environment_default.isTest()) {
7761
7819
  queue = new import_bull.default(jobQueue, queueConfig);
@@ -12761,6 +12819,8 @@ var init8 = (opts = {}) => {
12761
12819
  DEFAULT_TENANT_ID,
12762
12820
  DeprecatedViews,
12763
12821
  DocumentType,
12822
+ Duration,
12823
+ DurationType,
12764
12824
  EmailUnavailableError,
12765
12825
  ErrorCode,
12766
12826
  FeatureDisabledError,