Production only bug when clicking "back" button on certain routes - can not reproduce locally

Hey Meteor forum,

I’m neck deep in a weird bug over here. I recently deployed this site www.touchstonepc.com to galaxy. You can reproduce the bug by clicking “save me money” or “make me money” on the landing page and clicking the browser’s back button, then this error gets thrown. Disclaimer: this does not happen locally.

Update: I replaced flow-router with ostrio:flow-router-extra because it leverages updated dependencies, and the error is now a little more descriptive.

Uncaught TypeError: Cannot read property 'replace' of undefined

What’s undefined is the route path. Before going to the target route the function replaces "/" with "/the-target-path", but when clicking back the path is undefined instead of "/".

Is there a way to explicity tell meteor that the target route path is “/”?

Some things to note:

  • The back button works fine on every route except “shop insurance” and “signup”
  • After going back to the "/" route with FlowRouter.go("/") instead of clicking the browser back, the back button works fine, but it’s broken until that happens.
  • This bug happens with a user logged in and logged out
  • The error only fires when going back to the "/" route
  • I cannot reproduce this locally using the --production flag when building
  • I have tried explicitly defining the ROOT_URL enviornment variable

Hopefully somebody can shed some light on this problem!

Thanks,
Dylan

Hello @dylmcg ,

  1. What browser(s) you’re on?
  2. OS and its version?
  3. Meteor and ostrio:flow-router-extra versions?
  4. Do you have es5-shim package installed?

From quick tests on my macOS High Sierra I can reproduce it only in Safari 11. Chrome, Opera and Firefox are fine.
Error on my end:

TypeError: undefined is not an object (evaluating 't.replace')

Comes from page.js package.

Hey doc, thanks for the reply.

  1. Im on the most recent version of chrome, but I’ve tested it in FirefoxDeveloperEdition and Safari and am experiencing the same bug.
  2. OS is High Sierra v.10.13
  3. Meteor@1.5.2.2ostrio:flow-router-extra@3.4.0
  4. Yes - I have the es5-shim@4.6.15 package installed

I wonder what’s causing this to happen in production but not locally.

Could you share code responsible for click on Save Me Money button?

this is the click event

'click .js-to-shop'(e, instance) {
    analytics.track('Clicked "save me money"');
    FlowRouter.go('/shop-insurance');
}

and for good measure here’s the landing route code

FlowRouter.route('/', {
  action() {
    BlazeLayout.render('appLayout', { main: 'Landing_page' });
  },
  name: 'home'
});
  1. Is the /shop-insurance registered route?
  2. Could you try to FlowRouter.go('routeName'); by name?

@dr.dimitru

  1. Yes /shop-insurance is a route, very similar to the home route
  2. I switched the FlowRouter.go() calls to the route name instead of the path. Again this works great locally, but breaks in production…

:thinking: