magento2: JS error in console on checkout when recaptcha for checkout/placing order is not enabled
Preconditions (*)
- Magento 2.4.3
- ‘Stores > Configuration > Security > Google reCAPTCHA Storefront > Storefront > Enable for Checkout/Placing Order’ set to ‘No’ (that’s the default config)
Steps to reproduce (*)
- Add a product to cart
- Go to checkout
- Open element inspector, see the JS error
Expected result (*)
- No JS errors on checkout
- Besides not wanting to run into errors, I wouldn’t expect checkout to load any recaptcha JS when all the recaptcha options are not enabled.
Actual result (*)
- Error message from recaptcha JS:
knockout.js:3753 Uncaught TypeError: Unable to process binding "afterRender: function(){return renderReCaptcha() }"
Message: Cannot read property 'rendering' of undefined
at UiClass.initCaptcha (reCaptcha.js:117)
at UiClass.renderReCaptcha (reCaptcha.js:182)
at afterRender (eval at createBindingsStringEvaluator (knockout.js:3221), <anonymous>:3:134)
at init (after-render.js:17)
at knockout.js:3730
at Object.ignore (knockout.js:1563)
at knockout.js:3729
at Object.arrayForEach (knockout.js:168)
at applyBindingsToNodeInternal (knockout.js:3715)
at applyBindingsToNodeAndDescendantsInternal (knockout.js:3573)
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
ps. I think severity should be higher, because any dev working om checkout will spot this, and will be looking for a fix. (I first checked all of my modules, themes and 3rd party modules: it’s time consuming.)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 6
- Comments: 38 (25 by maintainers)
Hi @mrtuvn I would give it P2: Checkout doesn’t break (the recaptcha component isn’t used, so the JS error doesn’t actually hurt) it’s not critical and no work-around is needed, which follows P3 description.
But this is awful for developers working on checkout: I have several custom ui components, layout processors and mixins on any checkout i work on. If there’s an issue after upgrading, I will first look at my customisations, then at third party modules, then Magento.
Imagine every dev going through this process after seeing this issue, that’s a lot of wasted time - and a lot of unhappy devs.
For anyone looking for a patch on Magento v2.4.3-p1
github-issue-33741.patch@basvanpoppel ? install a clean instance of m2 you can’t checkout cause of those issues without reCaptcha configuration being enabled and valid means Magento2 does not work out of the box.
By default if extension is in system and is not configured to be used should mean no assets are included in storefront at all. Aim for this in your PR, thanks.
In addition to this:
I would have expected this to be released as a Magento Quality Patch, or is this issue too small for that?
Just a link for those looking for the actual SOLUTION https://github.com/magento/security-package/pull/302/commits/d25432de3b33946b88e93ddcfd01f5e898510a15
Just updated from 2.4.3 to 2.4.3-p1 and still experiencing this error in checkout unless reCAPTCHA is configured.
Errors being thrown due to optional configuration not being configured wastes a lot of time. As covered above when updating between versions going through a smashing any log exceptions or console errors thrown post upgrade is standard process and this error in checkout is just another distraction and another pointless issue to investigate. I don’t know why errors are seen as acceptable, when the goal should be 0 errors and warnings.
Is there actually going to be a fix put in place for this?
Unbelievable !!! we need the information what is finally be done to fix this issue. We do not want to wait till 2.4.3-p1 is out as it could take a few weeks/months till it is released.
@chittima: could you leave some more detailed info please? Like providing commits that fixed this. Just closing an issue with so little explanation is a bit rude … Also: have you tested this while
magento/security-packagewas installed? The comments above seem to indicate that the bug is part of that package.Looks like issue is already fixed. The issue is not reproducible on the latest 2.4-develop
p2 label is lower priority than p1/p0. It’s depend on specific case of ticket. It’s not related with fix order deliver to next release. i’m not sure magento team will deliver this fixes as patch (seperate) or regular fix as normal. I saw a pull request related in the case owner disabled captcha from backend but captcha js files still request from server. But we already have PR for that here Put here for anyone interesting https://github.com/magento/magento2/pull/33200. In this specific issue imho captcha js should only available if user put both user/key pair value in backend
Fix for the impatient (Magento composer installations).
@basvanpoppel -this implements your suggested PR (https://github.com/magento/security-package/pull/302) changes 😃
/patches/composer/github-issue-33741.diff/composer.jsonIt’s actually pretty close, the release of 2.4.3-p1 😉
Thanks @sdzhepa for the extra info, however it would still be nice if somebody could figure out how it got fixed.
The fix already mentioned above links