Conversation
…ded archive misbehaves Three ways the UI could go blank or throw out of a handler, on input it does not control: - localStorage was read while the settings reducer built its initial state. Safari in private browsing and a few privacy settings make every access throw, the store threw during creation, and the application never rendered. safeGetItem/safeSetItem answer "no stored value" instead; every localStorage use goes through them. - JSON.parse on a drag-and-drop payload (three sites), on story.json from an uploaded archive, and on the upload response body. parseJson answers undefined for anything that is not JSON; the drop handlers ignore it, the archive reader rejects with a message that names story.json (also when it is missing, which used to throw on null), and the upload rejects instead of resolving with a SyntaxError. - No error boundary: React 16 unmounts the whole tree on an uncaught render error. ErrorBoundary at the root shows the error and a reload button, in both languages and with no dependency on i18n or the store, since either may be what failed. Tests: storage (4, including a throwing accessor), parseJson (2), ErrorBoundary rendered into jsdom with react-dom (2), readFromArchive on a malformed and on a missing story.json (2). Closes #13 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
What
Three ways the UI could go blank or throw out of a handler, on input it does not control. All defensive, no behaviour change on valid input.
localStorageat startup. The settings reducer read it while building its initial state. Safari in private browsing and a few privacy settings make every access throw — the accessor itself included — so the store threw during creation and the application never rendered.safeGetItem/safeSetItem(utils/storage.js) answer "no stored value" instead; everylocalStorageuse (reducer,App.js,PackLibrary.js) goes through them.JSON.parseon untrusted input.parseJson(utils/json.js) answersundefinedfor anything that is not JSON. Applied to the three drag-and-drop handlers (ignore the payload),readFromArchive(rejects with a message namingstory.json, also when the file is missing — that used to throw onnull), and the upload XHR (rejects instead of resolving with aSyntaxError; the strayconsole.logthat stringified the parsed object is gone).No error boundary. React 16 unmounts the whole tree on an uncaught render error, which the user sees as a blank page.
ErrorBoundaryat the root shows the error and a reload button, in both languages, with no dependency on i18n or the store since either may be what failed.Tests
storage.test.js(4): pass-through, throwinggetItem, throwing accessor, failingsetItemjson.test.js(2)ErrorBoundary.test.js(2): rendered into jsdom withreact-domdirectly — no component testing library addedreader.test.js(2): malformed and missingstory.json, real zips built with JSZipLocally:
yarn test→ 67 passed (57 + 10);yarn buildcompiles underCI=true(warnings are errors there). Java untouched.Tracked in lgnap#13.
🤖 Generated with Claude Code