@budibase/server 2.6.19-alpha.31 → 2.6.19-alpha.35

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.
@@ -8,8 +8,8 @@
8
8
  <link rel="preconnect" href="https://fonts.gstatic.com" />
9
9
  <link href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@400;600;700&display=swap"
10
10
  rel="stylesheet" />
11
- <script type="module" crossorigin src="/builder/assets/index.3dd3d237.js"></script>
12
- <link rel="stylesheet" href="/builder/assets/index.8469b14c.css">
11
+ <script type="module" crossorigin src="/builder/assets/index.b6e30d5b.js"></script>
12
+ <link rel="stylesheet" href="/builder/assets/index.a96c516c.css">
13
13
  </head>
14
14
 
15
15
  <body id="app">
@@ -3441,9 +3441,76 @@ var init_users3 = __esm({
3441
3441
  // ../backend-core/src/redis/redlockImpl.ts
3442
3442
  var redlockImpl_exports = {};
3443
3443
  __export(redlockImpl_exports, {
3444
- doWithLock: () => doWithLock
3444
+ doWithLock: () => doWithLock,
3445
+ newRedlock: () => newRedlock
3445
3446
  });
3446
- var import_redlock, getClient, OPTIONS, newRedlock, doWithLock;
3447
+ async function getClient(type, opts) {
3448
+ if (type === "custom" /* CUSTOM */) {
3449
+ return newRedlock(opts);
3450
+ }
3451
+ if (environment_default2.isTest() && type !== "try_once" /* TRY_ONCE */) {
3452
+ return newRedlock(OPTIONS.TEST);
3453
+ }
3454
+ switch (type) {
3455
+ case "try_once" /* TRY_ONCE */: {
3456
+ return newRedlock(OPTIONS.TRY_ONCE);
3457
+ }
3458
+ case "try_twice" /* TRY_TWICE */: {
3459
+ return newRedlock(OPTIONS.TRY_TWICE);
3460
+ }
3461
+ case "default" /* DEFAULT */: {
3462
+ return newRedlock(OPTIONS.DEFAULT);
3463
+ }
3464
+ case "delay_500" /* DELAY_500 */: {
3465
+ return newRedlock(OPTIONS.DELAY_500);
3466
+ }
3467
+ default: {
3468
+ throw new Error(`Could not get redlock client: ${type}`);
3469
+ }
3470
+ }
3471
+ }
3472
+ async function newRedlock(opts = {}) {
3473
+ let options2 = { ...OPTIONS.DEFAULT, ...opts };
3474
+ const redisWrapper = await getLockClient();
3475
+ const client3 = redisWrapper.getClient();
3476
+ return new import_redlock.default([client3], options2);
3477
+ }
3478
+ function getLockName(opts) {
3479
+ const prefix = opts.systemLock ? "system" : getTenantId();
3480
+ let name = `lock:${prefix}_${opts.name}`;
3481
+ if (opts.resource) {
3482
+ name = name + `_${opts.resource}`;
3483
+ }
3484
+ return name;
3485
+ }
3486
+ async function doWithLock(opts, task) {
3487
+ const redlock = await getClient(opts.type, opts.customOptions);
3488
+ let lock;
3489
+ try {
3490
+ const name = getLockName(opts);
3491
+ lock = await redlock.lock(name, opts.ttl);
3492
+ const result = await task();
3493
+ return { executed: true, result };
3494
+ } catch (e) {
3495
+ console.warn("lock error");
3496
+ if (e.name === "LockError") {
3497
+ if (opts.type === "try_once" /* TRY_ONCE */) {
3498
+ return { executed: false };
3499
+ } else {
3500
+ console.error(e);
3501
+ throw e;
3502
+ }
3503
+ } else {
3504
+ console.error(e);
3505
+ throw e;
3506
+ }
3507
+ } finally {
3508
+ if (lock) {
3509
+ await lock.unlock();
3510
+ }
3511
+ }
3512
+ }
3513
+ var import_redlock, OPTIONS;
3447
3514
  var init_redlockImpl = __esm({
3448
3515
  "../backend-core/src/redis/redlockImpl.ts"() {
3449
3516
  import_redlock = __toESM(require("redlock"));
@@ -3451,33 +3518,14 @@ var init_redlockImpl = __esm({
3451
3518
  init_src();
3452
3519
  init_context2();
3453
3520
  init_environment3();
3454
- getClient = async (type, opts) => {
3455
- if (type === "custom" /* CUSTOM */) {
3456
- return newRedlock(opts);
3457
- }
3458
- if (environment_default2.isTest() && type !== "try_once" /* TRY_ONCE */) {
3459
- return newRedlock(OPTIONS.TEST);
3460
- }
3461
- switch (type) {
3462
- case "try_once" /* TRY_ONCE */: {
3463
- return newRedlock(OPTIONS.TRY_ONCE);
3464
- }
3465
- case "default" /* DEFAULT */: {
3466
- return newRedlock(OPTIONS.DEFAULT);
3467
- }
3468
- case "delay_500" /* DELAY_500 */: {
3469
- return newRedlock(OPTIONS.DELAY_500);
3470
- }
3471
- default: {
3472
- throw new Error(`Could not get redlock client: ${type}`);
3473
- }
3474
- }
3475
- };
3476
3521
  OPTIONS = {
3477
3522
  TRY_ONCE: {
3478
3523
  // immediately throws an error if the lock is already held
3479
3524
  retryCount: 0
3480
3525
  },
3526
+ TRY_TWICE: {
3527
+ retryCount: 1
3528
+ },
3481
3529
  TEST: {
3482
3530
  // higher retry count in unit tests
3483
3531
  // due to high contention.
@@ -3504,44 +3552,6 @@ var init_redlockImpl = __esm({
3504
3552
  retryDelay: 500
3505
3553
  }
3506
3554
  };
3507
- newRedlock = async (opts = {}) => {
3508
- let options2 = { ...OPTIONS.DEFAULT, ...opts };
3509
- const redisWrapper = await getLockClient();
3510
- const client3 = redisWrapper.getClient();
3511
- return new import_redlock.default([client3], options2);
3512
- };
3513
- doWithLock = async (opts, task) => {
3514
- const redlock = await getClient(opts.type, opts.customOptions);
3515
- let lock;
3516
- try {
3517
- const prefix = opts.systemLock ? "system" : getTenantId();
3518
- let name = `lock:${prefix}_${opts.name}`;
3519
- if (opts.resource) {
3520
- name = name + `_${opts.resource}`;
3521
- }
3522
- lock = await redlock.lock(name, opts.ttl);
3523
- const result = await task();
3524
- return { executed: true, result };
3525
- } catch (e) {
3526
- console.warn("lock error");
3527
- if (e.name === "LockError") {
3528
- if (opts.type === "try_once" /* TRY_ONCE */) {
3529
- console.warn(e);
3530
- return { executed: false };
3531
- } else {
3532
- console.error(e);
3533
- throw e;
3534
- }
3535
- } else {
3536
- console.error(e);
3537
- throw e;
3538
- }
3539
- } finally {
3540
- if (lock) {
3541
- await lock.unlock();
3542
- }
3543
- }
3544
- };
3545
3555
  }
3546
3556
  });
3547
3557
 
@@ -31991,6 +32001,7 @@ init_src();
31991
32001
  init_src2();
31992
32002
  var import_string_templates8 = __toESM(require_src2());
31993
32003
  var import_fp8 = require("lodash/fp");
32004
+ var import_perf_hooks2 = require("perf_hooks");
31994
32005
  init_utils15();
31995
32006
  init_environment();
31996
32007
  utils_default.threadSetup();
@@ -32167,7 +32178,7 @@ var Orchestrator = class {
32167
32178
  return;
32168
32179
  }
32169
32180
  }
32170
- const start2 = performance.now();
32181
+ const start2 = import_perf_hooks2.performance.now();
32171
32182
  for (let step of automation.definition.steps) {
32172
32183
  if (timeoutFlag) {
32173
32184
  break;
@@ -32351,9 +32362,12 @@ var Orchestrator = class {
32351
32362
  loopSteps = [];
32352
32363
  }
32353
32364
  }
32354
- const end2 = performance.now();
32365
+ const end2 = import_perf_hooks2.performance.now();
32355
32366
  const executionTime = end2 - start2;
32356
- console.log(`Execution time: ${executionTime} milliseconds`);
32367
+ console.info(`Execution time: ${executionTime} milliseconds`, {
32368
+ _logKey: "automation",
32369
+ executionTime
32370
+ });
32357
32371
  try {
32358
32372
  await storeLog2(this._automation, this.executionOutput);
32359
32373
  } catch (e) {