filog icon indicating copy to clipboard operation
filog copied to clipboard

Possible conflict with FlowRouter

Open arggh opened this issue 8 years ago • 2 comments

I'm currently unavailable to debug this further, but I noticed a possible issue:

I was finishing up testing FiLog (1.6), and as a final step I tried logging every route change from FlowRouter like this:

const trackRouteEntry = (context) => {
  logger.debug(`Route entry ${context.path}`, context.queryParams);
};

FlowRouter.triggers.enter([trackRouteEntry]);

I had setup FiLog like this:

// /client/main.js
const consoleSender = new ConsoleSender();
const meteorSender = new MeteorClientHttpSender(Meteor.absoluteUrl('/logger'));
const teeSender = new TeeSender([meteorSender, consoleSender]);
logger = new ClientLogger(new LeveledStrategy(
  teeSender,
  teeSender,
  teeSender
));


logger.processors.push(
  new BrowserProcessor(),
  new RoutingProcessor()
);

logger.arm();

Now, if I check what happens to FlowRouter's state, it's Router.queryParamsis populated by data from logger, depending on the processors in use:

{"browser":{"platform":"MacIntel","product":"Gecko","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36","performance":{}},"routing":{"location":{"hash":"","search":"","pathname":"/","port":"3000","hostname":"localhost","host":"localhost:3000","protocol":"http:","origin":"http://localhost:3000","href":"http://localhost:3000/","ancestorOrigins":{}}},"timestamp":{"log":1479647232743}}

And the next time I try to call

FlowRouter.setQueryParams({
    randomParam: 5,
    anotherParam: true
});

all that stuff from FiLog ends up in my path / browser address bar.

arggh avatar Nov 20 '16 13:11 arggh

I made a reproduction: https://github.com/arggh/filog-router-issue

arggh avatar Nov 20 '16 13:11 arggh

Looks like we are overwriting a global symbol. Weird. No time to look into it today and we don't have this problem with ReactRouter either, so not sure when I'll have the time to address this.

fgm avatar Nov 20 '16 14:11 fgm