Guard async toolbox/dialog callbacks against torn-down DOM / missing opts (BL-16574)#8081
Draft
hatton wants to merge 1 commit into
Draft
Guard async toolbox/dialog callbacks against torn-down DOM / missing opts (BL-16574)#8081hatton wants to merge 1 commit into
hatton wants to merge 1 commit into
Conversation
…opts (BL-16574) - TextBoxProperties.fillInLanguageNames(): the getBookLangs callback is async, so the Text Box Properties dialog may already be closed and its elements removed from the DOM by the time it resolves. Bail out instead of throwing on a null getElementById result (Sentry BLOOM-DESKTOP-FFJ). - LeveledReaderTool.beginRestoreSettings(): opts can be undefined when a book has no saved leveled-reader state. Optional-chain the lookup so it falls through to the default-level path instead of throwing an unhandled rejection that aborts tool activation (Sentry BLOOM-DESKTOP-FFH). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Member
Author
|
[Claude Sonnet 5] Consulted Devin on 2026-07-20 01:00 UTC up to commit 3c8329d. Result: 0 Bugs, 0 Investigate flags, 1 Informational flag (not posted — low signal; it assessed both guards as legitimate defensive fixes for genuine async lifecycle conditions, consistent with the repo's fail-fast policy which targets API misuse, not this). |
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.
[Claude Sonnet 5] Fix authored by Claude Opus 4.8; this PR was pushed and taken through preflight by Claude Sonnet 5.
Summary
Two small defensive guards for Sentry crash reports on BloomDesktop's front end:
TextBoxProperties.fillInLanguageNames()(SentryBLOOM-DESKTOP-FFJ): theeditView/getBookLangscallback is async, so the Text Box Properties dialog can already beclosed — and its elements removed from the DOM — by the time it resolves. The code used a
non-null assertion (
document.getElementById(...)!) and crashed with "Cannot readproperties of null" when that happened. Now it bails out if the elements are gone.
LeveledReaderTool.beginRestoreSettings(opts)(SentryBLOOM-DESKTOP-FFH):optscan beundefinedfor a book with no saved leveled-reader state, and the code indexed into itunconditionally, throwing "Cannot read properties of undefined (reading
'leveledReaderState')". Now it optional-chains the lookup so it falls through to the
default-level path instead.
Test plan
pnpm typecheck— cleanpnpm lint— 0 errors (pre-existing warnings elsewhere untouched)pnpm test:ci(full vitest suite) — 501 passed, 5 skipped, 0 failedRef: https://bloomlibrary.youtrack.cloud/issue/BL-16574
Devin review
This change is