Repository navigation
Conversation
Contributor
Author
|
Forgot to make an issue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This happened to us in production, so I made a fix.
For context, we use a single shared
Serverobject for the whole app and rely only onauto_reloginto keep the session alive. We never calllogin()manually after startup.When a request gets a
952(invalid token),auto_reloginsets_tokentoNoneand callslogin(). If that login throws (in our case most likely FileMaker Server being briefly unreachable), the token is never set again. From then on every request is sent without anAuthorizationheader, and FileMaker returns:auto_reloginonly reacts to952, so it never tries again, and the server object stays broken until the process is restarted.This fix keeps track of whether a relogin is still pending. If the last relogin failed, the next request tries to log in again before it's sent. The flag is cleared on a successful login, so an explicit
logout()is not undone byauto_relogin. I also added a unit test for the failed relogin case.Alternatively,
_with_auto_relogincould also relog on error 10 when there's no token:That needs
MISSING_DATA = 10added toFMSErrorCode. It's simpler, but it costs one failed request first and would undo an explicitlogout().