3 ms·
I spent an embarrassing amount of time debugging why some token refresh code that was supposed to trigger every 15 minutes didn't. Eventually I had to just pri
by mywittyname 2y ago
I spent an embarrassing amount of time debugging why some token refresh code that was supposed to trigger every 15 minutes didn't. Eventually I had to just print out the value for each variable and found that I defined 15 minutes as 15 * 60 * 60...
- water-your-self 2y agoI like defining constants with math.
- spacebanana7 2y agoI’ve encountered similar issues for long lived tokens in cookies on Safari. Turned out my Maths was okay, but Safari under many circumstances removes first party cookies after 7 days. https://snowplow.io/blog/tracking-cookies-length/ https://snowplow.io/blog/tracking-cookies-length/
- shepherdjerred 2y agoI find it easier to do something like: SECONDS_IN_MINUTE = 60 REFRESH_TIME_MINUTES = 15 REFRESH_TIME_SECONDS = SECONDS_IN_MINUTE * REFRESH_TIME_MINUTES e.g. I define every constant separately, and ideally any constant defined by an operation will only have one such operation. This makes mistakes _much_ easier to spot.
- psd1 2y agonew TimeSpan(minutes = 15)
- shepherdjerred 2y agoDepending on the language, this is definitely preferable!
- psd1 2y agoOh the places you'll go When you roll your own date You'll think you are great 'Til you're 6 minutes slow!