-
Notifications
You must be signed in to change notification settings - Fork 129
fix: Remove sequential execution limit from pm.execution.runRequest
#1544
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
ed594c6
b5762c2
6978e50
00cd1ab
3d277fa
8a5b850
f133df2
28f8abc
545668b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,9 +11,34 @@ function runNestedRequest ({ executionId, isExecutionSkipped, vaultSecrets, item | |
| const self = this, | ||
| requestResolver = _.get(self, 'options.script.requestResolver'), | ||
| runRequestRespEvent = EXECUTION_RUN_REQUEST_RESPONSE_EVENT_BASE + eventId, | ||
| maxInvokableNestedRequests = _.get(self, 'options.maxInvokableNestedRequests'); | ||
| maxInvokableNestedRequests = _.get(self, 'options.maxInvokableNestedRequests'), | ||
| itemId = item.id, | ||
|
|
||
| nestingChainMetaForCurrentItem = { popped: false }, | ||
|
||
| popCurrentItemFromNestingChain = () => { | ||
| if (nestingChainMetaForCurrentItem.popped) { return; } | ||
|
|
||
| nestingChainMetaForCurrentItem.popped = true; | ||
|
|
||
| if (!self.state.nestedRequest.nestingChain.length) { return; } | ||
|
|
||
| const nestingChain = self.state.nestedRequest.nestingChain, | ||
| itemIndex = nestingChain.lastIndexOf(itemId); | ||
|
|
||
| if (nestingChain[nestingChain.length - 1] === itemId) { | ||
| self.state.nestedRequest.nestingChain.pop(); | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| if (itemIndex !== -1) { | ||
| self.state.nestedRequest.nestingChain.splice(itemIndex, 1); | ||
| } | ||
appurva21 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
|
|
||
| function dispatchErrorToListener (err) { | ||
| popCurrentItemFromNestingChain(); | ||
|
|
||
| const error = serialisedError(err); | ||
|
|
||
| delete error.stack; | ||
|
|
@@ -28,15 +53,16 @@ function runNestedRequest ({ executionId, isExecutionSkipped, vaultSecrets, item | |
| isNestedRequest: true, | ||
| rootCursor: cursor, | ||
| rootItem: item, | ||
| invocationCount: 0 | ||
| nestingChain: [] | ||
| }); | ||
|
|
||
| self.state.nestedRequest.invocationCount++; | ||
| self.state.nestedRequest.nestingChain = self.state.nestedRequest.nestingChain || []; | ||
| self.state.nestedRequest.nestingChain.push(itemId); | ||
|
|
||
| // No more than maxInvokableNestedRequests runRequest calls per script or any of its nested request scripts | ||
| if (self.state.nestedRequest.invocationCount > maxInvokableNestedRequests) { | ||
| return dispatchErrorToListener(new Error('The maximum number of pm.execution.runRequest()' + | ||
| ' calls have been reached for this request.')); | ||
| // No more than maxInvokableNestedRequests nested depth | ||
| if (self.state.nestedRequest.nestingChain.length > maxInvokableNestedRequests) { | ||
| return dispatchErrorToListener(new Error('Max pm.execution.runRequest depth of ' + | ||
| maxInvokableNestedRequests + ' has been reached.')); | ||
| } | ||
|
|
||
| let rootRequestEventsList = self.state.nestedRequest.rootItem.events?.all?.() || [], | ||
|
|
@@ -137,6 +163,8 @@ function runNestedRequest ({ executionId, isExecutionSkipped, vaultSecrets, item | |
| variableMutationsFromThisExecution = {}; | ||
|
|
||
| if (err) { | ||
| popCurrentItemFromNestingChain(); | ||
|
|
||
| return self.host | ||
| .dispatch(EXECUTION_RUN_REQUEST_RESPONSE_EVENT_BASE + eventId, | ||
| requestId, err); | ||
|
|
@@ -206,6 +234,8 @@ function runNestedRequest ({ executionId, isExecutionSkipped, vaultSecrets, item | |
| delete error.stack; | ||
| } | ||
|
|
||
| popCurrentItemFromNestingChain(); | ||
|
|
||
| return self.host.dispatch(runRequestRespEvent, | ||
| requestId, error || null, | ||
| responseForThisRequest, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nestedRequest.callStack?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated