Has anybody else had issues with SMT content not s...
# suitecommerce
j
Has anybody else had issues with SMT content not showing up in Safari since this latest iOS update? All content added through the SMT is blank. No console errors, no nothing. Just blank… Toggling off the content blockers setting and refreshing seems to fix it about once every 5 times, but doesn’t seem to be consistent enough to be the definite cause.
m
Yes. My team received its first report late on Sunday. I opened a ticket with Netsuite. Believe it to be an issue with cms.js.
In localstorage, if you add an entry for SMT_DEBUG = T, you’ll see more activity in the browser console. This was the entire reason I needed to secure local dev (my thread from a few days ago)
We can reliably reproduce the issue in both desktop and mobile Safari.
j
@Mike Herrera No resolution yet from NetSuite, I take it?
m
Correct. The case is still open.
j
Do you have a case or defect number that I could reference in my case so they can see the two are related?
m
Support Case #: 5391175
j
Thank you
👍 1
m
@Jacob D have you heard back about your case? I’m stuck in the bureaucracy of the initial levels of support.
j
@Mike Herrera Yes, I’ve been going back and forth with them for a few days. It’s definitely not just us and definitely not just Kilimanjaro customers. I’ve seen it happen on at least 3 more sites. Hard to say what version they’re on, but I know one is 19.2. It sounds like it’s exclusively a SCA problem and doesn’t have anything to do with the NetSuite core, so it doesn’t matter if you’re on 23.1 or 23.2. Unfortunately, at least for us, it seems to affect all major browsers on iOS, not just Safari as well as Safari on desktop. Just about 10 minutes ago, they officially filed a U4 defect (number 738761) to be fixed in an upcoming e-Fix in 1-3 weeks. We’ve got probably our biggest launch of the year coming up in that time, so I’m trying to get them to bump it up to at least a U3. We’ll see, though… fingers crossed
m
Thank you for the info, @Jacob D. My Director of Marketing is irked that high-value iPhone users are having bad experiences.
j
Him and me both. I had no idea how much we were relying on SMT content util it’s gone. I’ve rebuilt our homepage to be hardcoded, but I’m not in a hurry to rebuild 80+ landing pages…
💯 1
m
Just confirmed, our case was attached to that same defect number.
fingers crossed 1
I was told that the defect was classified as a U5. 😞 So anywhere between 2 and 4'ish e-fix releases… so easily over a month. Oof. As a side-effect, I’ve followed suit and hardcoded our most important landing pages. Our lighthouse performance score went from 35 to 72 on the exact same page. Even when cms.js starts working again, it may be time to look for an alternative solution.
j
One of our devs came up with a quick and dirty solution in the interim. It’s pretty hacky, so use at your own risk, but it seems to work. Once I’m back at my desk, I’ll send it over.
👍 1
@Mike Herrera Here’s what we’ve got running now that seems to be mitigating the problem for us. (Insert NetSuite-style Safe Harbor Statement here about how I’m not responsible if this totally blows everything up). We put this in all of our SSP files (shopping.ssp, myaccount.ssp and checkout.ssp in the section that requires and loads the CMS:
Copy code
(function() {
                var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
                if (isSafari) {
                    var originalRemoveChild = Node.prototype.removeChild;

                    Node.prototype.removeChild = function(node) {
                        if (node.tagName === 'SCRIPT' && node.src.indexOf('/api/cms/v2/sites/cms-templates') !== -1) {
                            console.warn('Prevented removal of script:', node.src);
                            return node;
                        }
                        return originalRemoveChild.call(this, node);
                    };
                }
            })();
So, this:
Copy code
<% if (SC.Configuration.cms.useCMS) { %>
	<script>
		require(['jQuery', 'Backbone', 'underscore'], function (jQuery, Backbone, _) 
		{
			jQuery.getScript('/cms/<%= SC.Configuration.cms.adapterVersion %>/cms.js')
				.done(function()
				{
					CMS.trigger('cms:load');
				});
		});
	</script>
<% } %>
Becomes this:
Copy code
<% if (SC.Configuration.cms.useCMS) { %>
	<script>
		require(['jQuery', 'Backbone', 'underscore'], function (jQuery, Backbone, _)
		{
		    (function() {
                var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
                if (isSafari) {
                    var originalRemoveChild = Node.prototype.removeChild;

                    Node.prototype.removeChild = function(node) {
                        if (node.tagName === 'SCRIPT' && node.src.indexOf('/api/cms/v2/sites/cms-templates') !== -1) {
                            console.warn('Prevented removal of script:', node.src);
                            return node;
                        }
                        return originalRemoveChild.call(this, node);
                    };
                }
            })();

			jQuery.getScript('/cms/<%= SC.Configuration.cms.adapterVersion %>/cms.js')
				.done(function()
				{
					CMS.trigger('cms:load');
				});
		});
	</script>
<% } %>
If you haven’t already extended the SSP files, they’re located in
/Modules/suitecommerce/ShoppingApplication@4.1.0/SuiteScript
m
Thank you @Jacob D. We started down the path of patching cms.js. Didn’t think of this particular angle.
j
Yeah, I forgot to post the reason for the issue (we think). Here’s what I got from my dev: I think I’ve identified the root cause of the issue. The CMS script fails trying to load the CMS templates because it’s adding and removing the script tag before the
onload
event — which notifies that the templates are loaded and can continue with the CMS load — is fired. Here’s the function in the cms.js script:
Copy code
n.addTemplateScriptTag = function() {
    return new Promise((function(t, n) {
        var e = document.createElement("script");
        e.type = "text/javascript";
        e.src = "/api/cms/v2/sites/cms-templates";
        e.async = false;
        e.onload = function() {
            return t();
        };
        e.onerror = function() {
            return n(new Error("Template script failed to load."));
        };
        document.head.appendChild(e).parentNode.removeChild(e); // ---->>>>>>.  THE SCRIPT TAG SHOULD BE REMOVED ONLOAD OR ONERROR, OTHERWISE THE EVENTS MAY NOT FIRE
    }));
}
m
Encouraging news--the defect was raised to U3.
🎉 1
Looks like your dev nailed it. The diff shows that the strategy changed — it now adds the tag to the body and leaves it.