Repository navigation
Improve crash handling - #66
Merged
Merged
Conversation
…d data from breaking the app at startup
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.
If the browser's saved layout gets corrupted or isn't a valid layout file, the tracker shows a blank page every time it opens until the user manually clears browser storage. This is bad because there's no obvious indicator of what's wrong or how to fix it. Similarly, if a tracker issue occurs, the tracker page is also blank. This PR improves crash handling to prevent breakage and, if it happens, tell the user what occurred and how to fix it.
For layouts, malformed layouts now produce an error and fall back to the default layout. For the tracker, if an error occurs, an error message explaining what to check and a "Try again" button will now appear. If a saved session cannot be resumed for some reason, the button will now be turned off with an explanation. If a fatal crash occurs, a recovery screen will now appear with buttons to reload the page or reset saved data (the latter requires a double-click to confirm).
Additionally, dragging something outside the tracker onto it (such as a file from File Explorer onto one of the HashFrog icons) used to cause an error. Now, it is just ignored.
A few ways to test things:
localStorage.setItem("layout", JSON.stringify({ layoutConfig: { name: "Broken", width: 325, height: 650 }, components: [{ type: "table", elements: 42 }], }));in the browser console and then navigate tohttp://localhost:3000/trackermanually. You should get the crash screen which provides the error message, a button to reload (which doesn't help in this case) and a button to reset saved data (which will reset everything to default values and fix the error).localStorage.setItem("layout", "{corrupt")in the browser console and reload. The page should open with the default layout loaded instead of blank page..jsonor a.txtrenamed to.jsonin launcher. The app should produce a red alert and leave the current layout untouched.REACT_APP_API_URLto any bogus host and launch the tracker with check tracking. You should get an error screen with a "Try again" button.tracker_sessionto set"mq_dungeons_specific": 3and try to resume the session. The session should restore without that field instead of crashing.