@nsshunt/stsrunnerframework 2.0.4 → 2.0.6
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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import isNode from "detect-node";
|
|
1
2
|
import { ModelDelimeter, Sleep, defaultLogger } from "@nsshunt/stsutils";
|
|
2
3
|
import { Gauge } from "@nsshunt/stsobservability";
|
|
3
4
|
//#region \0rolldown/runtime.js
|
|
@@ -89,11 +90,6 @@ var PublishMessageCommandsTestRunner = {
|
|
|
89
90
|
ExecuteRefreshTokenResponse: "__ExecuteRefreshTokenResponse"
|
|
90
91
|
};
|
|
91
92
|
//#endregion
|
|
92
|
-
//#region node_modules/detect-node/browser.js
|
|
93
|
-
var require_browser$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
94
|
-
module.exports = false;
|
|
95
|
-
}));
|
|
96
|
-
//#endregion
|
|
97
93
|
//#region node_modules/color-name/index.js
|
|
98
94
|
var require_color_name = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
99
95
|
module.exports = {
|
|
@@ -1997,8 +1993,8 @@ var require_templates = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1997
1993
|
};
|
|
1998
1994
|
}));
|
|
1999
1995
|
//#endregion
|
|
2000
|
-
//#region
|
|
2001
|
-
var
|
|
1996
|
+
//#region src/abstractRunnerExecutionWorker.ts
|
|
1997
|
+
var import_source = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2002
1998
|
var ansiStyles = require_ansi_styles();
|
|
2003
1999
|
var { stdout: stdoutColor, stderr: stderrColor } = require_browser();
|
|
2004
2000
|
var { stringReplaceAll, stringEncaseCRLFWithFirstIndex } = require_util();
|
|
@@ -2142,11 +2138,7 @@ var require_source = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
2142
2138
|
chalk.stderr = Chalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
2143
2139
|
chalk.stderr.supportsColor = stderrColor;
|
|
2144
2140
|
module.exports = chalk;
|
|
2145
|
-
}));
|
|
2146
|
-
//#endregion
|
|
2147
|
-
//#region src/abstractRunnerExecutionWorker.ts
|
|
2148
|
-
var import_browser = /* @__PURE__ */ __toESM(require_browser$1());
|
|
2149
|
-
var import_source = /* @__PURE__ */ __toESM(require_source());
|
|
2141
|
+
})))());
|
|
2150
2142
|
import_source.default.level = 3;
|
|
2151
2143
|
/**
|
|
2152
2144
|
* Abstract worker-runtime base class.
|
|
@@ -2293,7 +2285,7 @@ var AbstractRunnerExecutionWorker = class {
|
|
|
2293
2285
|
this.#debug(import_source.default.grey(`WorkerInstance:#processLoopExecutor(): Removing runners from collection: [${removeList}]`));
|
|
2294
2286
|
for (let i = 0; i < removeList.length; i++) {
|
|
2295
2287
|
this.#runners[removeList[i]].archived = true;
|
|
2296
|
-
if (this.#archiveDeleteTimeout !== 0) if (
|
|
2288
|
+
if (this.#archiveDeleteTimeout !== 0) if (isNode) setTimeout(() => delete this.#runners[removeList[i]], this.#archiveDeleteTimeout * 1e3).unref();
|
|
2297
2289
|
else setTimeout(() => delete this.#runners[removeList[i]], this.#archiveDeleteTimeout * 1e3);
|
|
2298
2290
|
}
|
|
2299
2291
|
const message = `WorkerInstance:#processLoopExecutor(): Remaining Runner Count: [${Object.keys(this.#runners).length}]`;
|
|
@@ -2366,7 +2358,7 @@ var AbstractRunnerExecutionWorker = class {
|
|
|
2366
2358
|
#SetMessagePort = (workerMessagePort) => {
|
|
2367
2359
|
try {
|
|
2368
2360
|
this.#collectorCollectorPort = workerMessagePort.port;
|
|
2369
|
-
if (
|
|
2361
|
+
if (isNode) this.#collectorCollectorPort.on("message", (data) => {
|
|
2370
2362
|
this.#silly(`collectorCollectorPort on('message'): ${JSON.stringify(data)}`);
|
|
2371
2363
|
});
|
|
2372
2364
|
else this.#collectorCollectorPort.addEventListener("message", (data) => {
|
|
@@ -4884,7 +4876,7 @@ var STSMessageBroker = class {
|
|
|
4884
4876
|
* @param cb Callback used to handle unsolicited inbound messages.
|
|
4885
4877
|
*/
|
|
4886
4878
|
SetupMessagePortListener = (stsWorkerEx, cb) => {
|
|
4887
|
-
if (
|
|
4879
|
+
if (isNode) stsWorkerEx.messagePort.on("message", (data) => {
|
|
4888
4880
|
this._processInboundMessage(data, cb);
|
|
4889
4881
|
});
|
|
4890
4882
|
else stsWorkerEx.messagePort.addEventListener("message", (data) => {
|
|
@@ -5115,7 +5107,7 @@ var STSMessageBroker = class {
|
|
|
5115
5107
|
*/
|
|
5116
5108
|
GetPorts = () => {
|
|
5117
5109
|
const { port1, port2 } = new MessageChannel();
|
|
5118
|
-
if (!
|
|
5110
|
+
if (!isNode) port1.start();
|
|
5119
5111
|
return {
|
|
5120
5112
|
port1,
|
|
5121
5113
|
port2
|
|
@@ -5612,7 +5604,7 @@ var ArchiveManager = class {
|
|
|
5612
5604
|
* This is stored so the loop can be stopped later via {@link Terminate}.
|
|
5613
5605
|
*/
|
|
5614
5606
|
timeout;
|
|
5615
|
-
archiveDelTimeout;
|
|
5607
|
+
archiveDelTimeout = {};
|
|
5616
5608
|
/**
|
|
5617
5609
|
* Construct a new archive manager.
|
|
5618
5610
|
*
|
|
@@ -5730,17 +5722,21 @@ var ArchiveManager = class {
|
|
|
5730
5722
|
* This removes the runner from the active runtime graph after a delay.
|
|
5731
5723
|
*/
|
|
5732
5724
|
if (this.archiveDeleteTimeout !== 0) {
|
|
5733
|
-
|
|
5725
|
+
const delTimeoutId = v4();
|
|
5726
|
+
const delTimeout = setTimeout(() => {
|
|
5734
5727
|
try {
|
|
5735
5728
|
this.options.workerRegistry.DeleteRunner(workerEx.id, removeList[i].runnerId);
|
|
5736
5729
|
} catch (error) {
|
|
5737
5730
|
this.options.logger.error(`Error in: this.options.workerRegistry.DeleteRunner(${workerEx.id}, ${removeList[i].runnerId})`);
|
|
5738
5731
|
}
|
|
5732
|
+
delete this.archiveDelTimeout[delTimeoutId];
|
|
5739
5733
|
}, this.archiveDeleteTimeout * 1e3);
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5734
|
+
if (isNode) delTimeout.unref();
|
|
5735
|
+
this.archiveDelTimeout[delTimeoutId] = {
|
|
5736
|
+
workerId: workerEx.id,
|
|
5737
|
+
runnerId: removeList[i].runnerId,
|
|
5738
|
+
delTimeout
|
|
5739
|
+
};
|
|
5744
5740
|
}
|
|
5745
5741
|
}
|
|
5746
5742
|
}
|
|
@@ -5756,15 +5752,15 @@ var ArchiveManager = class {
|
|
|
5756
5752
|
* Schedule the next archive scan.
|
|
5757
5753
|
*/
|
|
5758
5754
|
this.timeout = setTimeout(() => this.ProcessLoopExecutor(), 1e3);
|
|
5759
|
-
if (
|
|
5755
|
+
if (isNode) this.timeout.unref();
|
|
5760
5756
|
}, 100);
|
|
5761
|
-
if (
|
|
5757
|
+
if (isNode) startTimeout.unref();
|
|
5762
5758
|
} else {
|
|
5763
5759
|
/**
|
|
5764
5760
|
* No archive candidates found; just schedule the next scan.
|
|
5765
5761
|
*/
|
|
5766
5762
|
this.timeout = setTimeout(() => this.ProcessLoopExecutor(), 1e3);
|
|
5767
|
-
if (
|
|
5763
|
+
if (isNode) this.timeout.unref();
|
|
5768
5764
|
}
|
|
5769
5765
|
} catch (error) {
|
|
5770
5766
|
this.options.logger.error(`_processLoopExecutor(): Error: [${error}]`);
|
|
@@ -5819,13 +5815,14 @@ var ArchiveManager = class {
|
|
|
5819
5815
|
*/
|
|
5820
5816
|
Terminate = () => {
|
|
5821
5817
|
this.options.logger.debug(`ArchiveManager:Terminate()`);
|
|
5818
|
+
this.options.logger.debug(`Runtime context: isNode = [${isNode}]`);
|
|
5822
5819
|
if (this.timeout) {
|
|
5823
5820
|
this.options.logger.debug(`ArchiveManager:Terminate() - this.timeout cleared ...`);
|
|
5824
5821
|
clearTimeout(this.timeout);
|
|
5825
5822
|
}
|
|
5826
|
-
if (this.archiveDelTimeout) {
|
|
5827
|
-
this.options.logger.debug(`ArchiveManager:Terminate() - this.archiveDelTimeout cleared
|
|
5828
|
-
clearTimeout(
|
|
5823
|
+
if (this.archiveDelTimeout) for (const [delKey, delTimeoutRecord] of Object.entries(this.archiveDelTimeout)) {
|
|
5824
|
+
this.options.logger.debug(`ArchiveManager:Terminate() - this.archiveDelTimeout: [${delKey}] cleared for workerId: [${delTimeoutRecord.workerId}] runnerId: [${delTimeoutRecord.runnerId}]`);
|
|
5825
|
+
clearTimeout(delTimeoutRecord.delTimeout);
|
|
5829
5826
|
}
|
|
5830
5827
|
};
|
|
5831
5828
|
};
|
|
@@ -6394,7 +6391,7 @@ var WorkerInstanceManager = class {
|
|
|
6394
6391
|
* @param stsWorkerEx Manager-side worker instance whose underlying actual worker should be monitored.
|
|
6395
6392
|
*/
|
|
6396
6393
|
SetupWorkerSystemEvents = (stsWorkerEx) => {
|
|
6397
|
-
if (
|
|
6394
|
+
if (isNode) {
|
|
6398
6395
|
/**
|
|
6399
6396
|
* Node.js worker thread exit event.
|
|
6400
6397
|
*
|