These are chat archives for reactioncommerce/reaction

4th
Aug 2016
Aaron Judd
@aaronjudd
Aug 04 2016 01:53
I’ve been experiencing random logouts. usually after a reaction reset in the first few seconds of the first session (where I’ve logged in). anyone else?
Spencer Norman
@spencern
Aug 04 2016 01:53
i’ve experienced similar things and had notes of “cookie tossing” in my console
sometimes I get the “unauthorized” template for the homepage if I’m logged out already on a reset and/or hot code reload
Brent Hoover
@zenweasel
Aug 04 2016 01:54
I was experiencing that yesterday but I had other tabs open and it seemed to stop it
Aaron Judd
@aaronjudd
Aug 04 2016 01:55
the cookie-tossing message is produced by fast-render, and I’ve been thinking we should look into removing that or resolving the root issue on that.
Brent Hoover
@zenweasel
Aug 04 2016 01:55
@spencern I think what you are seeing is reactioncommerce/reaction#1122
Aaron Judd
@aaronjudd
Aug 04 2016 01:56
and yup, I have #1122 assigned to me for the unauthorized thing..
I’m actually in the middle of a session, say processing the order, and I’ll get logged out randomly
first couple times I thought I was nuts, or that meteor had finally finished compiling and I was in an old session that finally reloaded, lol. not so sure now..
Brent Hoover
@zenweasel
Aug 04 2016 01:57
yeah, I was constantly resetting and starting over so I sort of discounted what I saw
I will give $5 to anyone who can invent a plugin that “dings” when Meteor is ready
Aaron Judd
@aaronjudd
Aug 04 2016 01:59
why so cheap?
Brent Hoover
@zenweasel
Aug 04 2016 01:59
how much do you want?
Spencer Norman
@spencern
Aug 04 2016 01:59
yeah, #1122 might be what I’m seeing as well
not sure that I’ve seen the force-logout thing then
Brent Hoover
@zenweasel
Aug 04 2016 02:00
also, not to hijack Aaron’s thread again but @spencern tell me if you see: reactioncommerce/reaction#1239
Aaron Judd
@aaronjudd
Aug 04 2016 02:01
ok, thanks @spencern well if I can figure out a way to replicate, I’ll add to #1122 when I dig into that, otherwise a bit of a ghost..
Spencer Norman
@spencern
Aug 04 2016 02:02
@zenweasel I’ll keep an eye out. Haven’t overwritten all templates yet so I haven’t started debugging some of the 404s that I’m getting, but definitely still seeing some.
Brent Hoover
@zenweasel
Aug 04 2016 02:03
this is one that gets solved by a refresh
but if you start seeing it, you can know you aren’t crazy (and neither am I hopefully)
Yin
@hinxcode
Aug 04 2016 05:19
Hello everyone, I have a question that is "Tags" a good product classification for shopping platform? Why not "Hierarchical" or other "Top-down"? Thanks in advance
hrath2015
@hrath2015
Aug 04 2016 06:05
@aaronjudd cookie tossing I see a on every fresh build. Refreshing the browser or open a new tab works well. Random logout I never noticed. My guess is U are seeing it on latest dev banch?
Antonin Hackenberg
@TondaHack
Aug 04 2016 14:42
Hi, How many shops based on reaction are in the production right now?
Sara Hicks
@saralouhicks
Aug 04 2016 14:45
@TondaHack Hi! We aren’t tracking that right now. We’ll put something in place to track and report production usage as we get closer to our public RC launch later this year.
Antonin Hackenberg
@TondaHack
Aug 04 2016 14:46
Do you have some estimation?
3Maestros
@3Maestros
Aug 04 2016 14:47
@saralouhicks on the same note can you share some of the top 5 stores that are using reaction commerce?
Sara Hicks
@saralouhicks
Aug 04 2016 14:48
@hinxcode Hi, great question. The short answer is we think so, primarily because we see “tags” as different than “navigation” where you can create hierarchy. We’ve seen tons of challenges with traditional commerce taxonomies. If you want, please add some thoughts in our forums and we can exchange some of our thinking there. https://forums.reactioncommerce.com/
@TondaHack and @3Maestros We don’t yet have estimates to provide or top 5s to share because we’re not tracking usage yet. We’ll definitely be sharing this information once we get closer to our public RC.
Antonin Hackenberg
@TondaHack
Aug 04 2016 15:15
@saralouhicks Thanks for quick response
Sara Hicks
@saralouhicks
Aug 04 2016 15:16
👍
Spencer Norman
@spencern
Aug 04 2016 20:51

Hey guys: I think I figuredo out why we were having trouble overriding certain templates, but would love confirmation and can send a PR if correct.
This line
https://github.com/reactioncommerce/reaction/blob/master/client/modules/router/main.js#L126
seems to overwrite the newLayout structure with whatever the default options are (options)

When I switch the order in Object.assign so that newLayout.structure is later, my template shows up as expected.

switch line 126 to
const layoutToRender = Object.assign({}, options, newLayout.structure, unauthorized);
Brent Hoover
@zenweasel
Aug 04 2016 20:59
Is that happening all the time, because if so I am not seeing that
Spencer Norman
@spencern
Aug 04 2016 20:59
That’s what I’m seeing on all overridden pages
bore out when I started logging
Brent Hoover
@zenweasel
Aug 04 2016 21:00
so that they never get used? Definitely don’t see that with a stock RC
Spencer Norman
@spencern
Aug 04 2016 21:00
  // autorun router rendering
  Tracker.autorun(function () {
    if (Reaction.Subscriptions.Shops.ready()) {
      const shop = Shops.findOne(Reaction.getShopId());
      if (shop) {
        console.log("Layout", layout);
        console.log("Workflow", workflow);
        const newLayout = shop.layout.find((x) => selectLayout(x, layout, workflow));
        console.log("newLayout", newLayout);
        // oops this layout wasn't found. render notFound
        if (!newLayout) {
          console.log("notFound");
          BlazeLayout.render("notFound");
        } else {
          console.log("options", options);
          console.log("unauthorized", unauthorized);
          const layoutToRender = Object.assign({}, options, unauthorized, newLayout.structure);
          console.log("rendering", layoutToRender);
          BlazeLayout.render(layout, layoutToRender);
        }
      }
    }
  });
  return options;
}
what I’m seeing is that newLayout becomes the correct layout
Brent Hoover
@zenweasel
Aug 04 2016 21:00
Yeah, mine looks similar
Spencer Norman
@spencern
Aug 04 2016 21:01
but layoutToRender gets overwritten by whatever the options object is
which in my case was the old layout
note that in my example above I’ve already switched the order of the args for Object.assign
Brent Hoover
@zenweasel
Aug 04 2016 21:02
When I was playing around with overriding templates, I was definitely not seeing it
Spencer Norman
@spencern
Aug 04 2016 21:02
I’m not fully sure where the options object comes from, so perhaps I’m supposed to set something else
Brent Hoover
@zenweasel
Aug 04 2016 21:04
Just woke up (it’s 5am here) but once I get some coffee I can try this and see what’s happening
Spencer Norman
@spencern
Aug 04 2016 21:04
yeah, was wondering why you’re on already ;)
Brent Hoover
@zenweasel
Aug 04 2016 21:09
you’re modifying everything through register.js correct?
Spencer Norman
@spencern
Aug 04 2016 21:09
correct
Brent Hoover
@zenweasel
Aug 04 2016 21:15
So trying it now with development and the example-plugin I am not seeing it
I am still getting that thing where it will occasionally look for coreLayout but 80% of the time it looks for the correct layout
hrath2015
@hrath2015
Aug 04 2016 21:18
can u print options as well and see what u get.
Brent Hoover
@zenweasel
Aug 04 2016 21:19
options Object {layout: "coreLayout", workflow: "coreWorkflow”}
Spencer Norman
@spencern
Aug 04 2016 21:20
how is that not overwriting the newLayout?
Brent Hoover
@zenweasel
Aug 04 2016 21:22
well, it would seem like it should except that it’s not:
rendering Object {template: "productsLanding", layoutHeader: "layoutHeader", layoutFooter: "layoutFooter", notFound: "productNotFound", dashboardControls: "dashboardControls"…}adminControlsFooter: "adminControlsFooter"dashboardControls: "dashboardControls"layout: "coreLayout"layoutFooter: "layoutFooter"layoutHeader: "layoutHeader"notFound: "productNotFound"template: "productsLanding"workflow: "coreWorkflow"__proto__: Object
but I am still getting my custom layout template
Because of this:
 console.log("rendering", layoutToRender);
  console.log("I am going to render: " + layout);
layout did not change, and options does not contain a template name
Spencer Norman
@spencern
Aug 04 2016 21:27
What template/workflow are you overriding?
I haven’t checked everything, but i’m seeing this behavior when overriding the productDetails template
Brent Hoover
@zenweasel
Aug 04 2016 21:27
I have overridden all the workflows with my coreLayoutBeesknees template
and this particular one with a “productsLanding” template
Spencer Norman
@spencern
Aug 04 2016 21:28

This is what my options object says it contains

{template: "productDetail", workflow: "coreProductWorkflow", layout: "coreLayout”}

Where does options come from and what is it’s purpose?
Brent Hoover
@zenweasel
Aug 04 2016 21:29
one difference between what you and I are doing is that you have added new records to Shops.layout and I have modified the existing records
Spencer Norman
@spencern
Aug 04 2016 21:29
correct
that seems like it should matter
Brent Hoover
@zenweasel
Aug 04 2016 21:29
I have always assumed options was for overriding this stuff programmatically
Spencer Norman
@spencern
Aug 04 2016 21:29
I’m trying to do as much of this as possible without forking any core packages
ah
Brent Hoover
@zenweasel
Aug 04 2016 21:30
Right, I don’t either
Spencer Norman
@spencern
Aug 04 2016 21:31
if that’s the case, then it seems like perhaps options should overwrite whatever the newLayout is, but also that options should default to being an empty object
Brent Hoover
@zenweasel
Aug 04 2016 21:31
function changeLayouts(shopId, newLayout) {
  check(shopId, String);
  check(newLayout, String);
  Logger.info(`::: changing all layouts to ${newLayout}`);
  let shop = Shops.findOne(shopId);
  for (let i = 0; i < shop.layout.length; i++) {
    shop.layout[i].layout = newLayout;
  }
  return Shops.update(shopId, {
    $set: {layout: shop.layout}
  });
}
Spencer Norman
@spencern
Aug 04 2016 21:31
or highly possible that I’m missing something
how did you modify existing Shops.layout without changing core?
Brent Hoover
@zenweasel
Aug 04 2016 21:32
well, I don’t have a clear grip on it yet but options won’t quite work there as expected. Because you already used layout + workflow to grab your record
maybe we have different definitions of what changing core means but: https://github.com/reactioncommerce/reaction-example-plugin/blob/master/server/init.js#L35
I am not suggesting you do that because you guys need to modify every record with different properties, just saying that might be why it’s (mostly) working for me
hrath2015
@hrath2015
Aug 04 2016 21:35
is it deployed somewhere to look at
Spencer Norman
@spencern
Aug 04 2016 21:35
yeah, definitely different approaches
not that one is better or worse, just different
I’m not currently deployed with my 0.14 update
Brent Hoover
@zenweasel
Aug 04 2016 21:36
but I am modifying the coreWorkflow the same way you are and still not having that issue
Spencer Norman
@spencern
Aug 04 2016 21:36
yeah
hrath2015
@hrath2015
Aug 04 2016 21:36
I helped earlier someone in debugging similar issue. Prior to .14.
Brent Hoover
@zenweasel
Aug 04 2016 21:36
the issue seems to be how you are getting that extra stuff in options
@hrath2015 I am pretty sure this issue is new to 14
hrath2015
@hrath2015
Aug 04 2016 21:36
can u reset the template to null and see.
only keep 2 options layout and workflow
Brent Hoover
@zenweasel
Aug 04 2016 21:37
Because this section of code has some hacks in it that are no longer there
Actually I am not pretty sure, I am 100% sure
hrath2015
@hrath2015
Aug 04 2016 21:37
u mean had
Brent Hoover
@zenweasel
Aug 04 2016 21:37
Yes, had
hrath2015
@hrath2015
Aug 04 2016 21:39
best bet would be to get rid of 3rd option which is template and see if it works in export function ReactionLayout(options = {}) {
Brent Hoover
@zenweasel
Aug 04 2016 21:40
so when you are grabbing the record by layout/workflow it’s grabbing the right record?
hrath2015
@hrath2015
Aug 04 2016 21:41
try 1 more thing instead of regular header use checkout header. If it works then problem is with template value coming in options.
that u have to update in registry, reset and restart
to be on safer side
Brent Hoover
@zenweasel
Aug 04 2016 21:44
@spencern To go back to your original post, the whole point of options is to override, so I don’t think changing the order of Object.assign is the correct approach
Spencer Norman
@spencern
Aug 04 2016 21:45
:+1: agreed, just trying to figure out how to not have options get set by default
Brent Hoover
@zenweasel
Aug 04 2016 21:45
yeah, this should be working correctly:
  const layout = options.layout || Session.get("DEFAULT_LAYOUT") || "coreLayout";
  const workflow = options.workflow || Session.get("DEFAULT_WORKFLOW") || "coreWorkflow”;
Spencer Norman
@spencern
Aug 04 2016 21:46
what file is that? I don’t think I’ve pulled latest dev in a couple days
Just about 50 lines up
Spencer Norman
@spencern
Aug 04 2016 21:47
Yep, got that
so somewhere, options is getting passed with an object that’s not empty
Brent Hoover
@zenweasel
Aug 04 2016 21:48
Yes, spooky
Brent Hoover
@zenweasel
Aug 04 2016 21:49
I think options is also slightly ineffective at what it’s trying to accomplish as well
hrath2015
@hrath2015
Aug 04 2016 21:49
I thinks this code is still there somewhere from V12 time if (ReactionCore.hasPermission(routeName, userId) || ReactionCore.hasPermission(route, userId)) { options.template = template; options.workflow = workflow; options.layout = layout; } else { // WIP - known issue with auth/login/reload options.template = "unauthorized"; options.workflow = workflow; options.layout = layout; }
I recall there was a PR from u @spencern for adding template as part of options.
wanna check please
just in case.
Brent Hoover
@zenweasel
Aug 04 2016 21:50
You can always pass in template, that’s how overriding layouts works
Spencer Norman
@spencern
Aug 04 2016 21:50
I don’t remember a specific PR, but definitely possible
Brent Hoover
@zenweasel
Aug 04 2016 21:52
I just have this suspicion that the original Shops.layout records are leaking in here somehow
Spencer Norman
@spencern
Aug 04 2016 21:52
yeah, that’s what feels most likely to me as well
Brent Hoover
@zenweasel
Aug 04 2016 21:52
in fact, I sort of don’t know how they wouldn't
hrath2015
@hrath2015
Aug 04 2016 22:35
There could be a possible mismatch in Registry while initializing routes and Routing table. Options are assigned based on registry definition. Whenever the route is run Options object is passed to render layout. It is expected both should match when route is run. If mis match then whatever is passed as options (at time of building routing table) will override the Shop Layout Definition. If all look fine(template name is same both in options and shop layout) then may be router is misbehaving. Not sure why. That could be the reason why @zenweasel is seeing 80% of time expected combination is used in example plugin.
hrath2015
@hrath2015
Aug 04 2016 22:46
one more thing to note. Here unauthorized super-seeds all. That is why sequence is layout structure, template to override and unauthorized in Object.assign({}, newLayout.structure, options, unauthorized)
Brent Hoover
@zenweasel
Aug 04 2016 22:51
Yeah, that is intentional so that if it’s set, unauthorized should be rendered
I think the issue I am seeing is a race condition with setting/getting DEFAULT.LAYOUT
but I think what @spencern is seeing is different and stickier, still trying to dig in and understand what is happening and what is supposed to happen
hrath2015
@hrath2015
Aug 04 2016 22:52
May be. I am planning to do some tests today using example plugin.
Hope to find something .