1

I have a rails api using devise-token-auth. Recently I was on really spotty/slow Wifi and I noticed I was getting 401's from my app. My theory is that the refreshing auth token is either being lost and delayed by the bad network. That being said, I'm having a hard time reproducing the bug itself.

Three primary questions:

  1. Could a spotty Wifi/network connection lead to 401s, due to loss or delay of the new auth-token. And if this is the case, is there a way to recover without needing the user to log back in.
  2. How to reproduce such an environment, so I can debug this scenario.
Alex
  • 1,977
  • 3
  • 13
  • 20

1 Answers1

1

I was able to reproduce it by delaying the server response using a debugger. In my case, this happens when I enable change_headers_on_each_request config, so when the response which carries the new tokens fails the next responses throw 401 code.

I recently sent an issue to the gem explaining this and asking how can I handle this situation on the frontend.

gegianno
  • 146
  • 4
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/low-quality-posts/19804405) – camille May 23 '18 at 01:22
  • I know this isn't a complete answer, but I couldn't add comments to the post because of my reputation. However, the answer confirms the theory of slow network problems and explains how to reproduce the bug for further debugging, which was one of the questions. What would have been the correct way for me to share this? – gegianno May 23 '18 at 03:03
  • 1
    @gegianno - FYI your answer was reviewed by six users (independently) and the votes split 3/3, erring on the side of keeping it intact. I voted to keep it because you did attempt to answer the question and provide the requested means to reproduce. If I had to _guess_ why others voted/commented against you, it may have something to do with the way you began your answer with "I'm having the same problem". (Makes it sound like a "me too" post rather than a useful answer.) I'd suggest leading with "I was able to reproduce in the following manner..." – William Price May 24 '18 at 03:15
  • Thanks for your input. I edited the answer as you suggested. – gegianno May 24 '18 at 13:06