Unknown error using Slate and Browser Sync

Highlighted
New Member
3 0 21

Hi there,

 

I am currently developing a theme for a client using Shopify Slate when the shop suddenly went down and I was presented with an error saying that I should try accessing the shop in a few minutes. I was able to access the shop a few minutes after and I got the following snippet of JavaScript being spit out:

 

"); } else { win._boomrl = function() { bootstrap(); }; if (win.addEventListener) { win.addEventListener("load", win._boomrl, false); } else if (win.attachEvent) { win.attachEvent("onload", win._boomrl); } } doc.close(); } var link = document.createElement("link"); if (link.relList && typeof link.relList.supports === "function" && link.relList.supports("preload") && ("as" in link)) { window.BOOMR.snippetMethod = "p"; link.href = window.BOOMR.url; link.rel = "preload"; link.as = "script"; link.addEventListener("load", promote); link.addEventListener("error", function() { iframeLoader(true); }); setTimeout(function() { if (!promoted) { iframeLoader(true); } }, LOADER_TIMEOUT); BOOMR_lstart = new Date().getTime(); where.parentNode.appendChild(link); } else { iframeLoader(false); } function boomerangSaveLoadTime(e) { window.BOOMR_onload = (e && e.timeStamp) || new Date().getTime(); } if (window.addEventListener) { window.addEventListener("load", boomerangSaveLoadTime, false); } else if (window.attachEvent) { window.attachEvent("onload", boomerangSaveLoadTime); } if (document.addEventListener) { document.addEventListener("onBoomerangLoaded", function(e) { e.detail.BOOMR.init({}); e.detail.BOOMR.t_end = new Date().getTime(); }); } else if (document.attachEvent) { document.attachEvent("onpropertychange", function(e) { if (!e) e=event; if (e.propertyName === "onBoomerangLoaded") { e.detail.BOOMR.init({}); e.detail.BOOMR.t_end = new Date().getTime(); } }); } })(); if (!isDuplicatedThankYouPageView()) { setCookieIfThankYouPage(); window.ShopifyAnalytics.lib.page( null, {"pageType":"password"} ); } }); var eventsListenerScript = document.createElement('script'); eventsListenerScript.async = true; eventsListenerScript.src="//cdn.shopify.com/s/assets/shop_events_listener-acf771159f9849ef6e5265782c99efe8b99406214c96a4373224ecafe285d7bb.js"; document.getElementsByTagName('head')[0].appendChild(eventsListenerScript); })();

It looks like it's coming from BrowerSync. Any ideas? 

10 Likes
Shopify Partner
7 0 1

same problem here, have you found any solution ?

0 Likes
New Member
1 0 1

same here:

image.png

1 Like
New Member
2 0 0

Same here! 

0 Likes
New Member
1 0 0

Same

0 Likes
New Member
3 0 21

Hey all!

 

I might have found a temporary solution if you are using Slate or Browser Sync. Add this code in node_modules/@Shopify/slate-tools/tools/dev-server/index.js within the bsConfig function.

 

snippetOptions: {
        rule: {
            match: /<head[^>]*>/i,
            fn: function(snippet, match) {
                return match + snippet;
            }
        }
    }
11 Likes
New Member
2 0 0

Thanks so much @josewl!! That worked

0 Likes
Shopify Partner
3 0 3

Same issue here, wish someone at Shopify would address this.

0 Likes
New Member
3 0 0

Great solution, but can you explain this at all?

What is browser-sync doing wrong when it tries to inject it's junk, that we need a new regex match function?

0 Likes
New Member
1 0 0

@josewl your solution worked for me, thanks!

0 Likes