m2-devtools icon indicating copy to clipboard operation
m2-devtools copied to clipboard

Cannot read property 'sectionLoadUrl' of undefined

Open mvenghaus opened this issue 5 years ago • 5 comments

Hey,

very nice tool .. real time saver!

Magento: 2.3.1

With the automatic generation I have 2 files that won't work. I think they are loaded to early. I removed them via empty .. then it works.

"Magento_Checkout/js/model/totals": "empty:", "Magento_Checkout/js/view/minicart": "empty:"

Would be nice if you can integrate a solution.

Regards Marcus

mvenghaus avatar Mar 28 '19 14:03 mvenghaus

Do you have a staging/QA server you can deploy this to so I could take a look? Without stack traces it's hard to know what's going on

DrewML avatar Mar 28 '19 18:03 DrewML

We have no public staging server :(

Do you have include minicart in your build.js?

The problem is that the script cannot access the data provided in the html.

"*":{"Magento_Customer\/js\/customer-data":{"sectionLoadUrl":"https:\/\/www.beutellos.de\/customer\/section\/load\/","expirableSectionLifetime":60,"expirableSectionNames":["cart","persistent"],"cookieLifeTime":"1209600","updateSessionUrl":"https:\/\/www.beutellos.de\/customer\/account\/updateSession\/"}}}

The sectionLoadUrl is not availaible when the minicart is loaded using the bundle.

mvenghaus avatar Mar 29 '19 07:03 mvenghaus

Do you have the bundled Paypal modules included (login/payment)? I believe there was a bug in there that I reported to them. If yes, I can dig up what the fix was.

Was a place where require('someDep') was used instead of define(['somedep'), function(someDep) {} at the top-level, which caused a race in some of the customer-data stuff due to the change in module initialization order.

DrewML avatar Mar 29 '19 22:03 DrewML

Ran into this issue on Magento 2.3.1, worked fine on 2.3.0.

Magento_Checkout/js/view/summary seems to be initiated before the customer-data constructor function is called. No issues with minicart on my end, also Magento_PayPal module is disabled and generated a new build.js.

Any thoughts @DrewML?

julian-van-drielen avatar Apr 16 '19 11:04 julian-van-drielen

The issue comes due to that sectionLoadUrl is loaded through x-mage-init. Because of bundles that is not loaded at the time the init functions that do things with customerData are fired. Resulting in this error.

We probably need to think of a way of getting customerData ready earlier or not using it in init functions cause they can be called before the x-mage-init is called.

rvr31 avatar May 09 '19 16:05 rvr31