synapsestudios / fetch-client

http client library based on fetch
MIT License
9 stars 3 forks source link

oauth: Simultaneous requests don't always correctly wait #112

Open spruce-bruce opened 5 years ago

spruce-bruce commented 5 years ago

Request timeline in screenshot:

  1. 3 requests made nearly simultaneously (POST /representative/cases, 2 GET /delivery-orders/{id}/history requests)
  2. /token request fires (eventually succeeds)
  3. The /cases request and one of the /history requests retry, both receive a 401
  4. the second /history request succeeds ("success" here defined as a 404, which is correct in this context)
  5. /token endpoint fires again
  6. first history request is retried, succeeds with a 404
  7. /cases endpoint tries again, succeeds with a 200

Screen Shot 2019-08-06 at 12 13 46 PM

If I had to guess I'd say that when we retry the request we aren't correctly using the new token. Also, why aren't tests catching this?