-
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
Merged
appurva21
merged 9 commits into
develop
from
update/remote-sequential-execution-limit-from-run-request
Mar 26, 2026
+277
−15
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ed594c6
fix: Remove sequential execution limit from `pm.execution.runRequest`
deve-sh b5762c2
Update changelog
deve-sh 6978e50
Update approach + add guards for nested loops
deve-sh 00cd1ab
Fix changelog
deve-sh 3d277fa
Rename nestingChain to callStack
deve-sh 8a5b850
Updated call stack state var name for item
deve-sh f133df2
Rename nestingChain to callStack
deve-sh 28f8abc
Remove irrelevant pop block
deve-sh 545668b
Remove redundant block of callStack initialization
deve-sh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,9 +11,33 @@ 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, | ||
| currentItemState = { isPoppedFromCallStack: false }, | ||
| popCurrentItemFromNestingChain = () => { | ||
| if (currentItemState.isPoppedFromCallStack) { return; } | ||
|
|
||
| currentItemState.isPoppedFromCallStack = true; | ||
|
|
||
| if (!self.state.nestedRequest.callStack.length) { return; } | ||
|
|
||
| const { callStack } = self.state.nestedRequest, | ||
| itemIndex = callStack.lastIndexOf(itemId); | ||
|
|
||
| if (callStack.at(-1) === itemId) { | ||
| self.state.nestedRequest.callStack.pop(); | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| if (itemIndex !== -1) { | ||
| self.state.nestedRequest.callStack.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 +52,16 @@ function runNestedRequest ({ executionId, isExecutionSkipped, vaultSecrets, item | |
| isNestedRequest: true, | ||
| rootCursor: cursor, | ||
| rootItem: item, | ||
| invocationCount: 0 | ||
| callStack: [] | ||
| }); | ||
|
|
||
| self.state.nestedRequest.invocationCount++; | ||
| self.state.nestedRequest.callStack = self.state.nestedRequest.callStack || []; | ||
|
||
| self.state.nestedRequest.callStack.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.callStack.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 +162,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 +233,8 @@ function runNestedRequest ({ executionId, isExecutionSkipped, vaultSecrets, item | |
| delete error.stack; | ||
| } | ||
|
|
||
| popCurrentItemFromNestingChain(); | ||
|
|
||
| return self.host.dispatch(runRequestRespEvent, | ||
| requestId, error || null, | ||
| responseForThisRequest, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
you can directly use the
destructuredvariablecallStackThere 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.
So I have preferred not updating the destructured variable as I am trying to ensure the mutations go to the self.state.nestedRequest object, which is shared across runs.
There was an issue in the app that gets fixed only if all mutations to nested properties go via this chain instead of a destructured variable.