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

executeRecaptcha hangs second time #13

Closed
olemartin opened this issue Oct 7, 2019 · 14 comments · Fixed by #14
Closed

executeRecaptcha hangs second time #13

olemartin opened this issue Oct 7, 2019 · 14 comments · Fixed by #14

Comments

@olemartin
Copy link

It seems like executeRecaptcha hangs the second time I call it. When users navigate on our site, we don't reload the script.

@t49tran
Copy link
Owner

t49tran commented Oct 7, 2019

Hi @olemartin, as much as I would like to, I cannot help you with such a brief, can you at least please provide an example of your code and the console log ?

@olemartin
Copy link
Author

@t49tran
I didnt know how to describe it better :-)

I have this code:

const { executeRecaptcha } = useGoogleReCaptcha();
vote() {
console.log('voting2');
        try {
            const captchaToken = await executeRecaptcha('voting_card');
            console.log('voting3');
...
}

voting2 is always printed, voting3 is only printed the first time.

In the application this happens when I use the backbutton to navigate back to where the recaptcha code is and execute the vote-function.

@t49tran
Copy link
Owner

t49tran commented Oct 8, 2019

So what you've caught inside the catch phrase, what is the error there ?

@olemartin
Copy link
Author

@t49tran It's no error. The function call just hangs.

@t49tran
Copy link
Owner

t49tran commented Oct 8, 2019

@t49tran It's no error. The function call just hangs.

Have you checked the function can reach the catch phrase, since you use try - catch there. The error might not be thrown into console log as it might be swallowed inside the catch phrase.

Without knowing the error I could not assist you further and must close this issue.

@olemartin
Copy link
Author

@t49tran I didn't have a try-catch in the start. I added the try-catch in an attempt to figure out what was wrong, but the function call just hangs. So, I don't have an error message, but the component doesn't work as expected.

@olemartin
Copy link
Author

It might be that the recaptcha token is expired. How do you handle that?

@olemartin
Copy link
Author

olemartin commented Oct 9, 2019

This seems to work:

const captchaToken2 = await window.grecaptcha.execute('secret', {
    action: 'kimh_banner',
});
const captchaToken = await executeRecaptcha('kimh_banner');

captchaToken2 gets a value, but captchaToken does not.

@turistua
Copy link

turistua commented Nov 5, 2019

I wonder if anyone looks at this issue?

@turistua
Copy link

turistua commented Nov 5, 2019

@olemartin we face this issue for gatsby websites. Do you develop static website as well?

@cahuizar
Copy link

I am also facing a similar issue as to what has been mentioned, the first time my app fully renders and I submit my form, the excuteRecaptcha returns back a value. But in the instance that it gets verified by the backend and or it expires. I get an error back from the API and if I try to resubmit values.RecaptchaToken = await executeRecaptcha('homepage'); addSmsInfo(values, setErrors);
the function call hangs and I never get a token back. I saw this mentioned on this #5 but anyway to generate a brand new token?

@Razum
Copy link

Razum commented Nov 11, 2019

+1
Have the same issue. executeRecaptcha method just returns Promise that is in "pending" state all the time

@akin-tekeoglu
Copy link

akin-tekeoglu commented Nov 13, 2019

@t49tran I opened PR. I tried it on my local machine and it worked. It doesn't hang when component remounts

@t49tran
Copy link
Owner

t49tran commented Nov 21, 2019

@akin-tekeoglu thanks for the PR, I will publish the fix as soon as possible.

@t49tran t49tran reopened this Nov 21, 2019
@t49tran t49tran closed this as completed Nov 25, 2019
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

Successfully merging a pull request may close this issue.

6 participants