Skip to content

fix: gate document:ready on script:loaded in PDF editor#134

Open
Alex-Arsys wants to merge 1 commit into
mainfrom
fix/error-editing-pdf-form
Open

fix: gate document:ready on script:loaded in PDF editor#134
Alex-Arsys wants to merge 1 commit into
mainfrom
fix/error-editing-pdf-form

Conversation

@Alex-Arsys

Copy link
Copy Markdown

The 500ms setTimeout before triggering document:ready was a race condition: postLaunchScripts (including the FormsTab view class) load asynchronously after app:ready, but in dev mode 30+ individual files consistently take longer than 500ms to load. When Toolbar.applyMode called FormsTab.setConfig before PDFE.Views.FormsTab was defined, createView received undefined as the view constructor, leaving _viewsCache in an inconsistent state and triggering EditingError -25 ("An error occurred during the work with the document").

After the 500ms minimum, check LaunchController.isScriptLoaded(). If scripts are still loading, defer fireDocumentReady until script:loaded fires — the same pattern already used throughout DocumentHolderExt, LeftMenu and Toolbar in this editor.

Fixes #38

Assisted-by: ClaudeCode:claude-sonnet-4-6

@Alex-Arsys Alex-Arsys self-assigned this Jun 22, 2026
@Alex-Arsys Alex-Arsys requested a review from a team as a code owner June 22, 2026 13:11
@Alex-Arsys Alex-Arsys requested review from emberfiend and moodyjmz and removed request for a team June 22, 2026 13:11
The 500ms setTimeout before triggering document:ready was a race
condition: postLaunchScripts (including the FormsTab view class) load
asynchronously after app:ready, but in dev mode 30+ individual files
consistently take longer than 500ms to load. When Toolbar.applyMode
called FormsTab.setConfig before PDFE.Views.FormsTab was defined,
createView received undefined as the view constructor, leaving
_viewsCache in an inconsistent state and triggering EditingError -25
("An error occurred during the work with the document").

After the 500ms minimum, check LaunchController.isScriptLoaded(). If
scripts are still loading, defer fireDocumentReady until script:loaded
fires — the same pattern already used throughout DocumentHolderExt,
LeftMenu and Toolbar in this editor.

Fixes #38

Assisted-by: ClaudeCode:claude-sonnet-4-6
Signed-off-by: Alex Hernández <ahmartin@arsys.es>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant