Skip to content

Commit 01c4936

Browse files
LMS007Kyle Keating
authored andcommitted
Merge pull request #23 from RapidAPI/step-timeout
Add step (http) timeout
1 parent a06f33c commit 01c4936

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

src/RapidTest.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ async function executeTest(testExecution, locationDetails) {
1313
...testExecution.envVariables,
1414
});
1515
try {
16-
testResult = await executable.eval(context, testExecution.test.timeoutSeconds);
16+
testResult = await executable.eval(
17+
context,
18+
testExecution.test.timeoutSeconds,
19+
testExecution.test.stepTimeoutSeconds
20+
);
1721
} catch (e) {
1822
consola.warn("Failed to execute test");
1923
consola.warn(e);

src/models/TestExecutable.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class TestExecutable {
5252
this.actions = actions;
5353
}
5454

55-
async eval(context, timeoutSeconds = 300) {
55+
async eval(context, timeoutSeconds = 300, stepTimeoutSeconds = 15) {
5656
//todo recursion
5757
var cancelled = false;
5858

@@ -76,13 +76,14 @@ class TestExecutable {
7676
if (cancelled) {
7777
break;
7878
}
79-
//1. materealize parameters -- recurcive replace based on context
79+
// 1. materialize parameters -- recursive replace based on context
80+
8081
action.updateParameters(recursiveReplace(action.parameters, context.data));
8182

8283
let result = { contextWrites: [], apiCalls: [], actionReports: [] };
8384
//2. evaluate action
8485
try {
85-
result = Object.assign(result, await action.eval(context));
86+
result = Object.assign(result, await action.eval(context, stepTimeoutSeconds));
8687
} catch (e) {
8788
result.actionReports = [
8889
{

src/models/actions/Http.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Http extends BaseAction {
1616
}
1717
}
1818

19-
async eval(context) {
19+
async eval(context, stepTimeoutSeconds = 15) {
2020
// fetch axios instance from context or create one if does not exist
2121
// this "shared" axios instance is used to ensure that cookies are properly passed between requests
2222
let transport;
@@ -47,7 +47,8 @@ class Http extends BaseAction {
4747
let response;
4848
const t0 = performance.now();
4949
let requestObj;
50-
const timeoutSeconds = (this.parameters.options && this.parameters.options.timeout) || 15;
50+
const timeoutSeconds = (this.parameters.options && this.parameters.options.timeout) || stepTimeoutSeconds;
51+
5152
requestObj = {
5253
url: this.parameters.url,
5354
method: this.method,

0 commit comments

Comments
 (0)