@midscene/test 1.12.3 → 1.12.4-beta-20260902110647.0
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/es/cli/index.mjs +33 -13
- package/dist/es/cli/index.mjs.map +1 -1
- package/dist/es/index.mjs +33 -13
- package/dist/es/index.mjs.map +1 -1
- package/dist/es/test-cli.mjs +33 -13
- package/dist/es/test-cli.mjs.map +1 -1
- package/dist/lib/cli/index.js +33 -13
- package/dist/lib/cli/index.js.map +1 -1
- package/dist/lib/index.js +33 -13
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/test-cli.js +33 -13
- package/dist/lib/test-cli.js.map +1 -1
- package/package.json +4 -4
package/dist/es/cli/index.mjs
CHANGED
|
@@ -829,30 +829,47 @@ async function executeNode(step, execute, phase, stepIndex, options) {
|
|
|
829
829
|
const startedAt = new Date();
|
|
830
830
|
const abortController = new AbortController();
|
|
831
831
|
const parentSignal = options.parentSignal;
|
|
832
|
-
const abortFromParent = ()=>abortController.abort(parentSignal?.reason
|
|
832
|
+
const abortFromParent = ()=>abortController.abort(parentSignal?.reason);
|
|
833
833
|
if (parentSignal?.aborted) abortFromParent();
|
|
834
834
|
else parentSignal?.addEventListener('abort', abortFromParent, {
|
|
835
835
|
once: true
|
|
836
836
|
});
|
|
837
837
|
const timeoutMs = step.meta.timeoutMs ?? options.defaultTimeoutMs;
|
|
838
838
|
let timeout;
|
|
839
|
-
let
|
|
839
|
+
let abortGraceTimeout;
|
|
840
840
|
const execution = Promise.resolve().then(()=>{
|
|
841
|
-
|
|
841
|
+
abortController.signal.throwIfAborted();
|
|
842
842
|
return execute(abortController.signal);
|
|
843
843
|
});
|
|
844
|
-
|
|
844
|
+
let settleOnAbort;
|
|
845
|
+
const abortedExecution = new Promise((_, reject)=>{
|
|
846
|
+
settleOnAbort = ()=>{
|
|
847
|
+
abortGraceTimeout = setTimeout(()=>{
|
|
848
|
+
reject(abortController.signal.reason);
|
|
849
|
+
}, 0);
|
|
850
|
+
};
|
|
851
|
+
if (abortController.signal.aborted) settleOnAbort();
|
|
852
|
+
else abortController.signal.addEventListener('abort', settleOnAbort, {
|
|
853
|
+
once: true
|
|
854
|
+
});
|
|
855
|
+
});
|
|
856
|
+
const timeoutExecution = void 0 === timeoutMs ? void 0 : new Promise((_, reject)=>{
|
|
857
|
+
timeout = setTimeout(()=>{
|
|
858
|
+
if (abortController.signal.aborted) return void reject(abortController.signal.reason);
|
|
859
|
+
const timeoutError = new StepTimeoutError(timeoutMs, step.node);
|
|
860
|
+
abortController.abort(timeoutError);
|
|
861
|
+
reject(timeoutError);
|
|
862
|
+
}, timeoutMs);
|
|
863
|
+
});
|
|
864
|
+
const settledExecution = Promise.race([
|
|
845
865
|
execution,
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
reject(timeoutError);
|
|
851
|
-
}, timeoutMs);
|
|
852
|
-
})
|
|
866
|
+
abortedExecution,
|
|
867
|
+
...void 0 === timeoutExecution ? [] : [
|
|
868
|
+
timeoutExecution
|
|
869
|
+
]
|
|
853
870
|
]);
|
|
854
871
|
try {
|
|
855
|
-
const output = validateNodeOutput(await
|
|
872
|
+
const output = validateNodeOutput(await settledExecution, step.node);
|
|
856
873
|
return {
|
|
857
874
|
...createStepResultBase(step, startedAt, phase, stepIndex),
|
|
858
875
|
status: 'success',
|
|
@@ -866,10 +883,12 @@ async function executeNode(step, execute, phase, stepIndex, options) {
|
|
|
866
883
|
...createStepResultBase(step, startedAt, phase, stepIndex),
|
|
867
884
|
status: 'failed',
|
|
868
885
|
continuedAfterError: step.meta.continueOnError,
|
|
869
|
-
error: normalizeNodeExecutionError(
|
|
886
|
+
error: normalizeNodeExecutionError(error, step.node)
|
|
870
887
|
};
|
|
871
888
|
} finally{
|
|
872
889
|
if (void 0 !== timeout) clearTimeout(timeout);
|
|
890
|
+
if (void 0 !== abortGraceTimeout) clearTimeout(abortGraceTimeout);
|
|
891
|
+
if (void 0 !== settleOnAbort) abortController.signal.removeEventListener('abort', settleOnAbort);
|
|
873
892
|
parentSignal?.removeEventListener('abort', abortFromParent);
|
|
874
893
|
}
|
|
875
894
|
}
|
|
@@ -884,6 +903,7 @@ async function executeStep(step, node, target, context, execution = {}) {
|
|
|
884
903
|
const stepIndex = 'case' === target.scope ? target.case.stepIndex : target.document.stepIndex;
|
|
885
904
|
return executeNode(step, async (signal)=>{
|
|
886
905
|
const input = await parseNodeInput(node, step.input);
|
|
906
|
+
signal.throwIfAborted();
|
|
887
907
|
const common = {
|
|
888
908
|
input,
|
|
889
909
|
$: step.meta,
|