marsidev / react-turnstile

Cloudflare Turnstile integration for React.
https://www.npmjs.com/package/@marsidev/react-turnstile
MIT License
414 stars 25 forks source link

Error: [Cloudflare Turnstile] Widget vihta to reset was not found.. #24

Closed mtn020990 closed 1 year ago

mtn020990 commented 1 year ago

when Turnstile got an error and we move to another page, Turnstile throws an error (see image) "@marsidev/react-turnstile": "^0.2.1"

image
marsidev commented 1 year ago

Hey! Thanks for submitting an issue.

Can you please provide more context about your stack/environment and share a reproducible example? Thanks in advance.

mtn020990 commented 1 year ago

I used the aways blocks key here: https://developers.cloudflare.com/turnstile/reference/testing/

image

the Turnstile widget auto-retry the challenge and I move to another page, it got that issue, I guess that the widget was destroyed but the code still get it to reset. I used React 18.

marsidev commented 1 year ago

Hey,

I was not able to reproduce the error. Check this codesandbox where I tried to replicate it.

Anyways, I added a try catch on the .reset() method to avoid the error (9bd3d9d017e859bd57103231f4c36df77785035f)

enlivn commented 7 months ago

@marsidev thanks for this library. I still see this crash on the following edge case: I'm using a valid turnstile site key and secret but on a domain that is unsupported (ie it is not configured as one of the domains on CF).

This would definitely fall under the category of programmer error but I wonder if we could fail more gracefully for new people adopting the library.

Stack track:

Uncaught TurnstileError: [Cloudflare Turnstile] Widget vz1i9 to reset was not found..
    u https://challenges.cloudflare.com/turnstile/v0/api.js?onload=onloadTurnstileCallback__cf-turnstile&render=explicit:1
    Xt https://challenges.cloudflare.com/turnstile/v0/api.js?onload=onloadTurnstileCallback__cf-turnstile&render=explicit:1
    t https://challenges.cloudflare.com/turnstile/v0/api.js?onload=onloadTurnstileCallback__cf-turnstile&render=explicit:1
    v https://challenges.cloudflare.com/turnstile/v0/api.js?onload=onloadTurnstileCallback__cf-turnstile&render=explicit:1
    S https://challenges.cloudflare.com/turnstile/v0/api.js?onload=onloadTurnstileCallback__cf-turnstile&render=explicit:1
    retryTimeout https://challenges.cloudflare.com/turnstile/v0/api.js?onload=onloadTurnstileCallback__cf-turnstile&render=explicit:1