-
-
Notifications
You must be signed in to change notification settings - Fork 654
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
Flake in waitingPeriodThreshold tests #5404
Comments
Hmm. Have you ever seen this locally? I don't think I have. If it has a higher chance of occurring in CI than locally, I'm not sure what the story would be. My first thought would be that we're failing to use My best idea, I think, would be to resolve the TODO:
because then we don't have to mess around with dates/times, like with My plan for the TODO would be:
|
I haven't naturally, but OTOH the only-what-changed behavior of I just tried it in a loop, and it failed 2 times out of 10:
|
That seems like a reasonable plan. Want to describe in a chat thread what you've tried and how it hasn't worked? The other possible direction is to debug why |
Ha, well, here it is! Added this debug-logging: const daysToAdd =
getRealm(newState).waitingPeriodThreshold + (waitingPeriodPassed ? 2 : -2);
- jest.setSystemTime(Date.parse(getOwnUser(newState).date_joined) + daysToAdd * 86400_000);
+ const target = Date.parse(getOwnUser(newState).date_joined) + daysToAdd * 86400_000;
+ console.log('setting time:', target, 'after joined:', getOwnUser(newState).date_joined);
+ jest.setSystemTime(target);
…
const { date_joined } = getUserForId(state, userId);
- const intervalLengthInDays = (Date.now() - Date.parse(date_joined)) / 86400_000;
+ const now = Date.now();
+ const intervalLengthInDays = (now - Date.parse(date_joined)) / 86400_000;
+ console.log('now is:', now, 'joined:', date_joined, 'interval days:', intervalLengthInDays); Then ran those tests in a loop:
Successful iterations:
Unsuccessful iteration:
So the problem is that I.e. it's this line in exampleData.js:
where oops, I'll fix. |
The NaN also explains why the flake was always in one direction: always false where we expected true, never (as far as I saw) vice versa. It's because NaN has the peculiar property that all comparison operators return false -- like the one at the end of |
First spotted here: #5401 (comment)
It looks like:
plus a similar one at:
#5402 cleaned up the date arithmetic, but the flake remains: #5393 (comment)
The code in question looks like:
Given that we've seen it a couple of times just this week, it seems to be a fairly high-frequency flake. That means it's a priority to fix -- but it's also good news for debugging it and testing potential fixes, because it suggests it may be reproducible just by running the test a small number of times.
The text was updated successfully, but these errors were encountered: