Skip to content

onError callback not triggered in some initialization failure scenarios #591

@Mati365

Description

@Mati365

onError callback not triggered in some initialization failure scenarios

Summary

The onError callback is not consistently invoked in certain failure cases during the _initializeEditor method in the CKEditor5 React component.

Details

There are two observed scenarios where onError is not called, even though an error is thrown internally and logged via the semaphore mechanism:

  1. When disableWatchdog=true:
    If the editor initialization fails and the watchdog is explicitly disabled, the onError callback is not triggered. The error is logged, but the consuming application cannot react to the failure via the provided hook.

  2. When the watchdog is enabled but fails to initialize the editor even once:
    In rare cases, the watchdog cannot initialize the editor successfully at all (e.g., due to configuration errors or external dependencies). In such cases, onError is also not triggered.

This inconsistent behavior can lead to silent failures in production, where applications relying on onError for error reporting, user notifications, or retries are left unaware of the problem.

Expected Behavior

The onError callback should be reliably called in any scenario where editor initialization fails, regardless of whether the watchdog is enabled or not.

Steps to Reproduce

  1. Set disableWatchdog: true
  2. Provide an invalid editor configuration that causes the editor to fail during _initializeEditor
  3. Observe that onError is not called, despite the failure being logged internally.

Possible Fix

Wrap all async calls inside the _initializeEditor method with appropriate try/catch blocks and explicitly invoke onError in the catch clauses. This includes, but is not limited to, the logic between lines 226–296 of ckeditor.tsx. Both watchdog-enabled and watchdog-disabled branches should propagate initialization errors via the onError callback.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions