I get a javascript error when any page is loaded with the recaptcha on it: Uncaught TypeError: grecaptcha.render is not a function

This happens because the attach function is called before window.drupalRecaptchaOnload. I added some code to check if the drupalRecaptchaOnload function has been called before any of the code in the attach function is executed.

Comments

markwittens created an issue. See original summary.

richardgaunt’s picture

Thank you, I had the same error and this patch has fixed it.

DaryaNN’s picture

I have the same problem. Please attach your file (/sites/all/modules/recaptcha/recaptcha.js) to the message.

craigshaddick’s picture

I seem to be getting this same issue on D7, would you mind uploading your complete recaptcha.js please so I can see if I can patch it for D7 also? I am trying to copy over the lines individually from your patch alone but it is not working for me as the JS file must have differences.

firestonej’s picture

Also getting this issue on D7. Patching D7 seems like it will be a bit more complicated since the JS is being added inline and there's preexisting @todos to clean it up.

hass’s picture

Category: Bug report » Support request
Status: Active » Postponed (maintainer needs more info)

This file is not from this project.

hass’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)
veronicaseveryn’s picture

Status: Closed (cannot reproduce) » Active
StatusFileSize
new204.41 KB
new174.78 KB

Which file is not from this project?

I am having the same issue in D7.

I have jQuery v 1.11
Drupal 7.59

The file recaptcha.js exists in Recaptcha module (7.x-2.2)

I am seeing issue intermittently.. Most times, it comes, then not.. But on some page refreshes it works.
I have also tried to fix it, but no luck yet..

Here's what I am seeing when it breaks:
screen1

screen2

hass’s picture

Status: Active » Postponed (maintainer needs more info)

I cannot see this JS file in https://cgit.drupalcode.org/recaptcha/tree/?h=7.x-2.x and also not in the release 7.x-2.2 or 8.x-2.x downloads.

veronicaseveryn’s picture

StatusFileSize
new1001 bytes

Ah, ok, yeah, I downloaded a fresh copy of Recaptcha v 2.2 and I see it's not there.

I just checked my project's Git history and it looks like it was added to my project Recaptcha's code from this issue:
https://www.drupal.org/project/recaptcha/issues/1833822#comment-12136661

I guess, that patch worked for one thing but breaks on something else...

Anyway, if anyone still needs a solution for D7, I attached the patch that worked for me.

I guess this issue can be closed.. I linked them both.

hass’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)
Parent issue: » #1833822: Allow multiple instances of reCAPTCHA on the same page

Better you update the broken patch in #1833822: Allow multiple instances of reCAPTCHA on the same page than posting another patch.

hass’s picture

The change looks strange as jquery .once() runs only once... no more.

benoit.marie’s picture

Hi @veronicaSeveryn,

I am using Drupal 7, Recaptcha 7.x-2.2 and couldn't see the .js file to apply the patch. Could you please tell me from where I could do it? Should I create one an upload it on the main folder of the module?

Thank you in avance.

Best,