Skip to content
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

after script executed one extra time for while loop #463

Closed
yanghua-ola opened this issue May 28, 2023 · 2 comments
Closed

after script executed one extra time for while loop #463

yanghua-ola opened this issue May 28, 2023 · 2 comments

Comments

@yanghua-ola
Copy link
Contributor

Given below http file:

###
# get project items
# @name get_project_items

{{
  exports.pageInfo = {
    hasNextPage: true,
  };
}}

# @loop while pageInfo.hasNextPage

GET https://github.com/postsadf

?? status == 200
{{@after
    pageInfo.hasNextPage = false;
    console.log("triggered")
}}

I expected "triggered" to be printed once. In reality, it would be printed twice. Other hooks, e.g. "response", "responseLogging" don't have this problem.

@yanghua-ola yanghua-ola changed the title after script executed one extra time forwhile loop after script executed one extra time for while loop May 28, 2023
@AnWeber
Copy link
Owner

AnWeber commented May 29, 2023

It was important to me not to introduce any special logic for the loop logic in other plugins. For this reason while works similar to ref only that a copy of the current region is always called. When the loop is terminated, however, I have to cancel the current execution, but I must not use any cancellation in the process. For this reason I put the current execution index at the last index. Unfortunately I did not think about the interceptor. I'll see how I can deactivate it correctly.

@AnWeber
Copy link
Owner

AnWeber commented Jun 2, 2023

I have not been able to solve it completely without adjusting the logic on the outside. I have therefore extended my hook concept so that any interceptor can abort the execution without error. It will go with the next release.

@AnWeber AnWeber closed this as completed Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants