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

using api steps in sub-scripts results in error - XMLHttpRequest Exception 101 #228

Closed
kensoh opened this issue Jul 3, 2018 · 7 comments
Labels

Comments

@kensoh
Copy link
Member

kensoh commented Jul 3, 2018

raising from user email


Not sure whether you have encountered this before so was hoping you or your colleagues have some possible solutions -

In our sub-scripts, we tried to perform an API call but got the following error message:

NETWORK_ERR: XMLHttpRequest Exception 101: A network error occurred in synchronous requests.

After much troubleshooting, we realise that the API call will only work on a main script. However it is not feasible to move the chunks of codes (> 1000 lines of codes!) from the sub-scripts to the main script for future maintenance purposes.

Appreciate any input on this.

@kensoh
Copy link
Member Author

kensoh commented Jul 3, 2018

Thanks for raising this! Can you email me some super-basic scripts without sensitive info which can replicate this issue?

We haven't come across this, if you are referring to main scripts and sub-scripts as files which you invoke using tagui step, the way tagui step works is it expands the contents of the sub-scripts to fill into the main script and run it just like a single script.

I suspect it might be related to web security protection settings used by TagUI. Inside tagui\src\tagui_config.txt, try changing the following lines to false, false, true to see if that helps. By default TagUI doesn't allow access to external URLs (eg API calls) that is outside of the webpages you explicitly scripted to visit.

webSecurityEnabled: true,
ignoreSslErrors: false,
localToRemoteUrlAccessEnabled: false

Also, if you have information when your scripts start to stop working, or if they have not worked before, that will be helpful.

@kensoh kensoh closed this as completed Jul 3, 2018
@kensoh kensoh added the query label Jul 3, 2018
@kensoh
Copy link
Member Author

kensoh commented Jul 3, 2018

reference - likely the line where issue happens

# check if api call is made in automation flow file to set appropriate setting for phantomjs to work
api=""; if [ -f "$1" ]; then if grep -iq "api http" "$1"; then api=" --web-security=false"; fi; fi

@kensoh
Copy link
Member Author

kensoh commented Jul 4, 2018

reply from user

Here are the sample scripts that would replicate the issue. We tried changing the web security settings as per your suggestion but it did not resolve the issue.

@kensoh kensoh reopened this Jul 4, 2018
@kensoh kensoh added bug and removed query labels Jul 4, 2018
kensoh added a commit that referenced this issue Jul 4, 2018
solution works by doing a keyword (api http) check in the generated js file instead of the source script. because a source script can call other sub-scripts and the detection of the keyword will not be found.
@kensoh
Copy link
Member Author

kensoh commented Jul 4, 2018

Above commit works now in cutting edge version - https://github.com/kelaberetiv/TagUI#set-up

solution works by doing a keyword (api http) check in the generated js file instead of the source script. because a source script can call other sub-scripts and the detection of the keyword will not be found. but by checking the generated js file, all sub-scripts would already been factored into consideration.

@kensoh kensoh closed this as completed Jul 4, 2018
kensoh added a commit that referenced this issue Jul 5, 2018
!! is needed for delayed variable expansion instead of %% for the variable api as it is in a for loop
@kensoh
Copy link
Member Author

kensoh commented Jul 5, 2018

Above commit makes it work for Windows -

!! is needed for delayed variable expansion instead of %% for the variable api as it is in a for loop

@ramu-yarru
Copy link

Hi Ken,

We are also facing similar error when invoking an API. I didn'y understand the solution that you have given above. Can you please elaborate on the above solution that you have given

Thanks,
Ramu

@kensoh
Copy link
Member Author

kensoh commented Mar 18, 2019

Hi Ramu, this change has already been committed and already be in current version (download from zip and overwrite with cutting edge version). How TagUI does this is search if you use api step in your script or sub-scripts. If yes, it will disable a security feature enabled by default that prevents you from accessing another website (API calls for eg) from the main website you are in.

https://github.com/kelaberetiv/TagUI#set-up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants