-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(fix) Wait for slugify to show up before returning slug #4049
(fix) Wait for slugify to show up before returning slug #4049
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should do the trick for now. However, note that Promise.await
is not in the ES6 spec. It's a method added to Promise
by Meteor and wouldn't function outside of the Meteor context. Normally I'd recommend just using async/await with getSlug
, but that would cause getSlug
to return a Promise instead of a string and you'd have to go update every instance of that function across the app. Probably not worth all of that trouble right now. We can always do that whenever getSlug
ends up in a non-Meteor context.
Standby. Failing test may be related to this change.
This definitely appears to be causing failing tests on both CircleCI and local. I'm also noticing that lib Lines 14 to 34 in a3b5cb5
Lines 191 to 209 in a3b5cb5
|
I don't know about the other places, but the place it's getting called here is from a schema so it seems like it needs to be in |
Tests fail if you remove the code that just swallows the error so... |
@jshimko Take a look at this and tell me if you think this makes sense |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like that fixed the failing tests and everything appears to be working as it should.
Resolves #4011
Impact: major
Type: bugfix
Issue
We weren't waiting for slugify to be resolved and if it wasn't resolved we just returned an empty string, which completely crashes the app. For some reason when reimporting the Basic Product this created a race condition where slugify was not loaded before this product was imported.
Test Problem:
The tests were failing because the code here: was trying to run a Meteor method that was not available yet: (this method literally just returns
Meteor.userId()
)reaction/server/api/core/core.js
Line 378 in fe7d125
It wasn't an actual test failing but the app not starting. It was the fact that we were masking the failure to get
slugify
that was allowing tests to pass in the past.I didn't find a solution to this problem but I did realize that the
lazyLoadSlugify
function was usinggetShopId
to determine the language but in the context of the server we don't have a user and we should be using the primary shop to determine language, so I created agetPrimaryShopLang
function.Solution
Promise.await
rather thanresolve
. I also removed the check forslugify
that just bailed and returned an empty string because I can't see why we would want that.To fix the
getShopId
problem we are grabbing the primary shop id when running on the server and the shop of the client when running client code.Testing
Fix Testing
devtools
loaded. (or you can drop theProducts
collection after the app is loaded)Regression Testing