Skip to content

bug(doc-editor): lazy plugin loader race — 'No document loader registered for .docx' #245

@abbaye

Description

@abbaye

Context

DocumentEditorHost.OpenAsync threw 'No document loader registered for .docx' because PluginActivationService.ActivateIfNeeded is fire-and-forget (Task.Run). The DocumentLoadersPlugin hadn't finished registering when the loader lookup ran. Fixed across two commits.

Root cause (commit 6bb6405c)

Poll ExtensionRegistry every 200ms for up to 3s before failing, giving the lazy plugin time to register its IDocumentLoader extensions.

Second failure (commit 02eaac1d)

The polling loop always timed out because FileOpenedEvent had not yet been published when OpenAsync started — MainWindow publishes it after tab creation, which is after OpenAsync is already running.

Fix: when no IDocumentLoader matches, publish FileOpenedEvent directly from DocumentEditorHost (via _ideContext.IDEEvents) before polling. This triggers PluginActivationService.OnFileOpened synchronously, enqueuing the plugin load. The 3s poll then sees the loader appear within ~200–400ms.

Files affected

  • Controls/DocumentEditorHost.xaml.cs

Follow-up

  • Replace polling with a proper IDocumentLoaderRegistered event from ExtensionRegistry
  • Guard against double FileOpenedEvent publish if MainWindow later also publishes it

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions