veliovgroup / flow-router

🚦 Carefully extended flow-router for Meteor
https://packosphere.com/ostrio/flow-router-extra
BSD 3-Clause "New" or "Revised" License
201 stars 30 forks source link

Invalid Regular Expression - 3.7.0 #68

Closed jasongrishkoff closed 4 years ago

jasongrishkoff commented 4 years ago

Just upgraded to 3.7.0 and am getting the following error:

Uncaught SyntaxError: Invalid regular expression: /^\/about\/refund(?:\/(?=$))?$/: Stack overflow
    at RegExp.exec (<anonymous>)
    at Route.match (ostrio_flow-router-extra.js?hash=96883db4695d24ad4599b4bf3f9da15a27a28f8d:3808)
    at ostrio_flow-router-extra.js?hash=96883db4695d24ad4599b4bf3f9da15a27a28f8d:3789
    at nextEnter (ostrio_flow-router-extra.js?hash=96883db4695d24ad4599b4bf3f9da15a27a28f8d:3338)
    at ostrio_flow-router-extra.js?hash=96883db4695d24ad4599b4bf3f9da15a27a28f8d:3790
    at nextEnter (ostrio_flow-router-extra.js?hash=96883db4695d24ad4599b4bf3f9da15a27a28f8d:3338)
    at ostrio_flow-router-extra.js?hash=96883db4695d24ad4599b4bf3f9da15a27a28f8d:3790
    at nextEnter (ostrio_flow-router-extra.js?hash=96883db4695d24ad4599b4bf3f9da15a27a28f8d:3338)
    at ostrio_flow-router-extra.js?hash=96883db4695d24ad4599b4bf3f9da15a27a28f8d:3790
    at nextEnter (ostrio_flow-router-extra.js?hash=96883db4695d24ad4599b4bf3f9da15a27a28f8d:3338)

The error leads to this function, with m = this.regexp.exec(decodeURIComponent(pathname)); causing the issue.

 Route.prototype.match = function(path, params) {
    var keys = this.keys,
      qsIndex = path.indexOf('?'),
      pathname = ~qsIndex ? path.slice(0, qsIndex) : path,
      m = this.regexp.exec(decodeURIComponent(pathname));

    if (!m) return false;

    for (var i = 1, len = m.length; i < len; ++i) {
      var key = keys[i - 1];
      var val = this.page._decodeURLEncodedURIComponent(m[i]);
      if (val !== undefined || !(hasOwnProperty.call(params, key.name))) {
        params[key.name] = val;
      }
    }

    return true;
  };

My route for that one looks like this:

import { FlowRouter } from 'meteor/ostrio:flow-router-extra'
FlowRouter.route('/about/refund', {
    name: 'refund',
    async action(params, queryParams) {
        const { default: Layout } = await import('/client/layout')
        const {
            default: AboutRefund
        } = await import('/imports/client/terms/refund')
        mount(Layout, {
            content: <AboutRefund />,
        })
    }
})

Am I doing something dumb here?

dr-dimitru commented 4 years ago

Hello @jasongrishkoff ,

Thank you for reporting about this issue. Please, for further investigation update this thread following [our ISSUE_TEMPLATE]():

Have you tried to run meteor reset and then meteor update? As it looks like your page.js library wasn't updated to the latest release (by comparing code from OP and [source code]((https://github.com/visionmedia/page.js/blob/master/page.js#L1185))? Please, be careful with meteor reset as it would wipe out your local MongoDB.

Reported exception leads to this line of code in page.js NPM lib which is used internally by FlowRouter.

jasongrishkoff commented 4 years ago

Thanks for getting back @dr-dimitru.

I went ahead and ran meteor reset (took a while!) and plenty of meteor update lines... and still no luck. Exact same error.

dr-dimitru commented 4 years ago

@jasongrishkoff could you please post contents of your package.json? Or just make sure you have meteor-node-stubs package installed and updated to the latest available version. Also check if there is any other outdated NPM packages with meteor npm outdated

jasongrishkoff commented 4 years ago

Hi @dr-dimitru, my meteor-node-stubs is at 0.4.1. Running npm oudated results in the following:

autolinker     2.2.1   2.2.2  3.11.0
bcrypt         1.0.3   1.0.3   3.0.6
papaparse      4.6.3   4.6.3   5.1.0
react         16.8.6  16.9.0  16.9.0
react-dom     16.8.6  16.9.0  16.9.0
shepherd.js    2.5.0  2.10.0   5.0.1
dr-dimitru commented 4 years ago

@jasongrishkoff please try latest v3.7.1 release this issue should be fixed.

Feel free to close it in case if the issue is solved on your end.

jasongrishkoff commented 4 years ago

Fixed!