Closed jtomaszewski closed 2 years ago
Note, this hasn't resolved the root issue. A few days a day we get a Sentry event about this this error happening. Result is: user clicks "Add to cart" button and nothing happens.
It's very difficult to reproduce though. (Maybe it depends on network speed and JS loading order?) And because of that I'm not yet able to tell how it should be fixed.
I tried to reproduce it and I was able to see the bug only twice, on list view mode, when I was clicking on add to cart button very fast, maybe before the whole page was loaded. We would like to merge your fix, thank you for your contribution. Could you only remove console.warn
and place the warning in a comment?
The thing is, the issue is still there ;( We've been trying hard to reproduce and fix it; but it seems to be quite difficult to repro it (I couldn't do it; my friend made it once or twice though. And we know our customers do repro it on a daily basis, as we get Sentry warnings about it - in our own theme, we have Sentry.captureException
instead of the console.warn
.)
Hello @jtomaszewski Thank you for pointing out this issue. We saw it a few times in our projects, but indeed it is hard to catch. We decided to create an internal ticket to investigate why these elements can be unavailable instead of applying checks. Sorry for the delays with our Github activity, but we have to keep the focus on our projects. However, we'll try to catch up more frequently with MRs. We will keep this open and let you know if we find anything.
@jtomaszewski Some time ago we introduce a check to adtocart.ts file
The concept is quite similar to you changes, scripts is not executed if there is no $component variable, which is:
this._$component = $('.atc-ajax-processing').closest(
.${this._options.componentClass}
);`
It seems to me that your PR can be closed now.
It'll hide the error from Sentry that's for sure. Whether that fixes the original error (assuming it exists - person clicks "add to cart" button and it does nothing), I don't know. I guess we can close it, until somebody reports it.
We have quite a bit of errors on Sentry that look like this:
Not sure yet how exactly it can be reproduced. But this should fix it. You already have such a check at https://github.com/magesuite/theme-creativeshop/blob/next/src/components/addtocart/addtocart.ts#L268 , so seems like it's just missing at the other places.