@budibase/server 2.6.19-alpha.30 → 2.6.19-alpha.31
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/automation.js +72 -28
- package/dist/automation.js.map +3 -3
- package/dist/index.js +54 -17
- package/dist/index.js.map +3 -3
- package/dist/query.js +4 -0
- package/dist/query.js.map +2 -2
- package/package.json +9 -8
- package/src/automations/logging/index.ts +21 -0
- package/src/environment.ts +1 -0
- package/src/threads/automation.ts +45 -28
- package/src/threads/index.ts +9 -3
- package/src/threads/utils.ts +2 -0
package/dist/index.js
CHANGED
|
@@ -3648,6 +3648,7 @@ var init_logger = __esm({
|
|
|
3648
3648
|
}
|
|
3649
3649
|
const mergingObject = {
|
|
3650
3650
|
err: error2,
|
|
3651
|
+
pid: process.pid,
|
|
3651
3652
|
...contextObject
|
|
3652
3653
|
};
|
|
3653
3654
|
if (objects.length) {
|
|
@@ -12063,6 +12064,7 @@ var init_environment3 = __esm({
|
|
|
12063
12064
|
ENABLE_ANALYTICS: process.env.ENABLE_ANALYTICS,
|
|
12064
12065
|
SELF_HOSTED: process.env.SELF_HOSTED,
|
|
12065
12066
|
HTTP_MB_LIMIT: process.env.HTTP_MB_LIMIT,
|
|
12067
|
+
FORKED_PROCESS_NAME: process.env.FORKED_PROCESS_NAME || "main",
|
|
12066
12068
|
// old
|
|
12067
12069
|
CLIENT_ID: process.env.CLIENT_ID,
|
|
12068
12070
|
_set(key, value) {
|
|
@@ -24371,13 +24373,17 @@ var init_threads = __esm({
|
|
|
24371
24373
|
this.count = opts.count ? opts.count : 1;
|
|
24372
24374
|
this.disableThreading = this.shouldDisableThreading();
|
|
24373
24375
|
if (!this.disableThreading) {
|
|
24376
|
+
console.debug(
|
|
24377
|
+
`[${environment_default2.FORKED_PROCESS_NAME}] initialising worker farm type=${type}`
|
|
24378
|
+
);
|
|
24374
24379
|
const workerOpts = {
|
|
24375
24380
|
autoStart: true,
|
|
24376
24381
|
maxConcurrentWorkers: this.count,
|
|
24377
24382
|
workerOptions: {
|
|
24378
24383
|
env: {
|
|
24379
24384
|
...process.env,
|
|
24380
|
-
FORKED_PROCESS: "1"
|
|
24385
|
+
FORKED_PROCESS: "1",
|
|
24386
|
+
FORKED_PROCESS_NAME: type
|
|
24381
24387
|
}
|
|
24382
24388
|
}
|
|
24383
24389
|
};
|
|
@@ -24387,6 +24393,10 @@ var init_threads = __esm({
|
|
|
24387
24393
|
}
|
|
24388
24394
|
this.workers = (0, import_worker_farm.default)(workerOpts, typeToFile(type), ["execute"]);
|
|
24389
24395
|
_Thread.workerRefs.push(this.workers);
|
|
24396
|
+
} else {
|
|
24397
|
+
console.debug(
|
|
24398
|
+
`[${environment_default2.FORKED_PROCESS_NAME}] skipping worker farm type=${type}`
|
|
24399
|
+
);
|
|
24390
24400
|
}
|
|
24391
24401
|
}
|
|
24392
24402
|
shouldDisableThreading() {
|
|
@@ -24398,9 +24408,7 @@ var init_threads = __esm({
|
|
|
24398
24408
|
function fire(worker) {
|
|
24399
24409
|
worker.execute(job, (err, response2) => {
|
|
24400
24410
|
if (err && err.type === "TimeoutError") {
|
|
24401
|
-
reject(
|
|
24402
|
-
new Error(`Query response time exceeded ${timeout2}ms timeout.`)
|
|
24403
|
-
);
|
|
24411
|
+
reject(new Error(`Thread timeout exceeded ${timeout2}ms timeout.`));
|
|
24404
24412
|
} else if (err) {
|
|
24405
24413
|
reject(err);
|
|
24406
24414
|
} else {
|
|
@@ -24737,8 +24745,10 @@ function makeVariableKey(queryId, variable) {
|
|
|
24737
24745
|
}
|
|
24738
24746
|
function threadSetup() {
|
|
24739
24747
|
if (environment_default2.isTest() || environment_default2.DISABLE_THREADING || !environment_default2.isInThread()) {
|
|
24748
|
+
console.debug(`[${environment_default2.FORKED_PROCESS_NAME}] thread setup skipped`);
|
|
24740
24749
|
return;
|
|
24741
24750
|
}
|
|
24751
|
+
console.debug(`[${environment_default2.FORKED_PROCESS_NAME}] thread setup running`);
|
|
24742
24752
|
init10();
|
|
24743
24753
|
}
|
|
24744
24754
|
async function checkCacheForDynamicVariable(queryId, variable) {
|
|
@@ -37486,10 +37496,26 @@ var init_AutomationEmitter = __esm({
|
|
|
37486
37496
|
});
|
|
37487
37497
|
|
|
37488
37498
|
// src/automations/logging/index.ts
|
|
37499
|
+
function sanitiseResults(results) {
|
|
37500
|
+
const message = `[removed] - max results size of ${MAX_LOG_SIZE_MB}MB exceeded`;
|
|
37501
|
+
for (let step of results.steps) {
|
|
37502
|
+
step.inputs = {
|
|
37503
|
+
message
|
|
37504
|
+
};
|
|
37505
|
+
step.outputs = {
|
|
37506
|
+
message,
|
|
37507
|
+
success: step.outputs.success
|
|
37508
|
+
};
|
|
37509
|
+
}
|
|
37510
|
+
}
|
|
37489
37511
|
async function storeLog2(automation, results) {
|
|
37490
37512
|
if (environment_default2.DISABLE_AUTOMATION_LOGS) {
|
|
37491
37513
|
return;
|
|
37492
37514
|
}
|
|
37515
|
+
const bytes = (0, import_object_sizeof.default)(results);
|
|
37516
|
+
if (bytes / MB_IN_BYTES > MAX_LOG_SIZE_MB) {
|
|
37517
|
+
sanitiseResults(results);
|
|
37518
|
+
}
|
|
37493
37519
|
await automations_exports.logs.storeLog(automation, results);
|
|
37494
37520
|
}
|
|
37495
37521
|
async function checkAppMetadata(apps2) {
|
|
@@ -37514,17 +37540,21 @@ async function checkAppMetadata(apps2) {
|
|
|
37514
37540
|
}
|
|
37515
37541
|
return apps2;
|
|
37516
37542
|
}
|
|
37543
|
+
var import_object_sizeof, MAX_LOG_SIZE_MB, MB_IN_BYTES;
|
|
37517
37544
|
var init_logging3 = __esm({
|
|
37518
37545
|
"src/automations/logging/index.ts"() {
|
|
37519
37546
|
init_environment3();
|
|
37520
37547
|
init_src4();
|
|
37521
37548
|
init_src2();
|
|
37549
|
+
import_object_sizeof = __toESM(require("object-sizeof"));
|
|
37550
|
+
MAX_LOG_SIZE_MB = 5;
|
|
37551
|
+
MB_IN_BYTES = 1024 * 1024;
|
|
37522
37552
|
}
|
|
37523
37553
|
});
|
|
37524
37554
|
|
|
37525
37555
|
// src/threads/automation.ts
|
|
37526
|
-
function getLoopIterations(loopStep
|
|
37527
|
-
|
|
37556
|
+
function getLoopIterations(loopStep) {
|
|
37557
|
+
let binding = loopStep.inputs.binding;
|
|
37528
37558
|
if (!binding) {
|
|
37529
37559
|
return 0;
|
|
37530
37560
|
}
|
|
@@ -37585,7 +37615,6 @@ var init_automation4 = __esm({
|
|
|
37585
37615
|
constructor(job) {
|
|
37586
37616
|
let automation = job.data.automation;
|
|
37587
37617
|
let triggerOutput = job.data.event;
|
|
37588
|
-
let timeout2 = job.data.event.timeout;
|
|
37589
37618
|
const metadata = triggerOutput.metadata;
|
|
37590
37619
|
this._chainCount = metadata ? metadata.automationChainCount : 0;
|
|
37591
37620
|
this._appId = triggerOutput.appId;
|
|
@@ -37719,7 +37748,7 @@ var init_automation4 = __esm({
|
|
|
37719
37748
|
});
|
|
37720
37749
|
}
|
|
37721
37750
|
async execute() {
|
|
37722
|
-
var _a2;
|
|
37751
|
+
var _a2, _b2;
|
|
37723
37752
|
this._context.env = await getEnvironmentVariables2();
|
|
37724
37753
|
let automation = this._automation;
|
|
37725
37754
|
let stopped = false;
|
|
@@ -37738,6 +37767,7 @@ var init_automation4 = __esm({
|
|
|
37738
37767
|
return;
|
|
37739
37768
|
}
|
|
37740
37769
|
}
|
|
37770
|
+
const start2 = performance.now();
|
|
37741
37771
|
for (let step of automation.definition.steps) {
|
|
37742
37772
|
if (timeoutFlag) {
|
|
37743
37773
|
break;
|
|
@@ -37756,20 +37786,16 @@ var init_automation4 = __esm({
|
|
|
37756
37786
|
}
|
|
37757
37787
|
if (loopStep) {
|
|
37758
37788
|
input = await (0, import_string_templates8.processObject)(loopStep.inputs, this._context);
|
|
37759
|
-
iterations = getLoopIterations(loopStep
|
|
37789
|
+
iterations = getLoopIterations(loopStep);
|
|
37760
37790
|
}
|
|
37761
37791
|
for (let index2 = 0; index2 < iterations; index2++) {
|
|
37762
37792
|
let originalStepInput = (0, import_fp8.cloneDeep)(step.inputs);
|
|
37763
37793
|
if (loopStep && input.binding) {
|
|
37764
|
-
let newInput = await (0, import_string_templates8.processObject)(
|
|
37765
|
-
loopStep.inputs,
|
|
37766
|
-
(0, import_fp8.cloneDeep)(this._context)
|
|
37767
|
-
);
|
|
37768
37794
|
let tempOutput = { items: loopSteps, iterations: iterationCount };
|
|
37769
37795
|
try {
|
|
37770
|
-
|
|
37796
|
+
loopStep.inputs.binding = typecastForLooping(
|
|
37771
37797
|
loopStep,
|
|
37772
|
-
|
|
37798
|
+
loopStep.inputs
|
|
37773
37799
|
);
|
|
37774
37800
|
} catch (err) {
|
|
37775
37801
|
this.updateContextAndOutput(loopStepNumber, step, tempOutput, {
|
|
@@ -37782,7 +37808,7 @@ var init_automation4 = __esm({
|
|
|
37782
37808
|
}
|
|
37783
37809
|
let item = [];
|
|
37784
37810
|
if (typeof loopStep.inputs.binding === "string" && loopStep.inputs.option === "String") {
|
|
37785
|
-
item = stringSplit(
|
|
37811
|
+
item = stringSplit(loopStep.inputs.binding);
|
|
37786
37812
|
} else if (Array.isArray(loopStep.inputs.binding)) {
|
|
37787
37813
|
item = loopStep.inputs.binding;
|
|
37788
37814
|
}
|
|
@@ -37925,7 +37951,18 @@ var init_automation4 = __esm({
|
|
|
37925
37951
|
loopSteps = [];
|
|
37926
37952
|
}
|
|
37927
37953
|
}
|
|
37928
|
-
|
|
37954
|
+
const end2 = performance.now();
|
|
37955
|
+
const executionTime = end2 - start2;
|
|
37956
|
+
console.log(`Execution time: ${executionTime} milliseconds`);
|
|
37957
|
+
try {
|
|
37958
|
+
await storeLog2(this._automation, this.executionOutput);
|
|
37959
|
+
} catch (e) {
|
|
37960
|
+
if (e.status === 413 && ((_b2 = e.request) == null ? void 0 : _b2.data)) {
|
|
37961
|
+
delete e.request.data;
|
|
37962
|
+
e.request.data = { message: "removed due to large size" };
|
|
37963
|
+
}
|
|
37964
|
+
logging_exports.logAlert("Error writing automation log", e);
|
|
37965
|
+
}
|
|
37929
37966
|
if (isProdAppID2(this._appId) && isRecurring(automation) && metadata) {
|
|
37930
37967
|
await this.updateMetadata(metadata);
|
|
37931
37968
|
}
|