Pending Review
Last Updated: 16 Nov 2026 09:32 by Holger
Holger
Created on: 16 Nov 2026 09:32
Category: Kendo UI for Angular
Type: Bug Report
0
Grid toolbar: uncancelled text-initialization timer accesses a destroyed injector

Grid toolbar: uncancelled text-initialization timer accesses a destroyed injector (NG0205)

Environment

  • @progress/kendo-angular-grid: 26.0.0
  • @progress/kendo-angular-toolbar: 26.0.0
  • Angular: 22.2.6, zoneless change detection
  • Original test runner: Jasmine 7.0.2 / Karma 6.4.4
  • Reproduced independently in Chrome Headless 157.0.0.0 on Linux

Summary

Destroying a grid and its environment injector before the next timer turn causes an uncaught NG0205: Injector has already been destroyed error when the grid contains a kendo-toolbar-button with kendoGridAddTool and no explicit text.

The original occurrence is in Angular unit tests with normal teardown: {destroyAfterEach: true}. Synchronous component tests create/render the grid and finish before the toolbar's text-initialization timer runs. Jasmine reports the escaped asynchronous error as "An error was thrown in afterAll".

The attached standalone reproduction requires neither Karma nor Jasmine.

Reproduction

Import the attached project into StackBlitz, or use the accompanying HTML launcher. Save/fork the resulting StackBlitz and include its URL with this report.

  1. Start the Angular application (npm install, then npm start locally).
  2. Click Control: explicit text.
    • The grid is created/rendered and then synchronously destroyed along with its dedicated environment injector.
    • No uncaught error occurs.
  3. Click Reproduce: no explicit text.
    • The identical lifecycle runs, but the toolbar button omits text.
    • An asynchronous NG0205 error appears in the page and browser console.

Relevant template:

<kendo-grid [data]="[]">
  <kendo-toolbar>
    <kendo-toolbar-button kendoGridAddTool />
  </kendo-toolbar>
</kendo-grid>

The control adds text="Add" to the same button. No other lifecycle behavior changes. The reproduction explicitly destroys the environment injector to model the original TestBed teardown; it does not claim that every ordinary component removal destroys the application injector.

Expected behavior

Destroying the grid and its injector should cancel or safely ignore pending initialization work. No callback should mutate a destroyed toolbar button or try to register a render callback with a destroyed injector.

Actual behavior

An uncaught asynchronous error is thrown:

Error: NG0205: Injector has already been destroyed.
    at assertNotDestroyed
    at R3Injector.get
    at ChainedInjector.get
    at lookupTokenUsingModuleInjector
    at getOrCreateInjectable
    at NodeInjector.get
    at afterEveryRenderImpl
    at afterNextRender
    at ToolBarButtonComponent.setTextDisplayMode
    at set text

Source-level findings

In the distributed 26.0.0 packages:

  • @progress/kendo-angular-grid/fesm2022/progress-kendo-angular-grid.mjs
    • ToolbarToolBase.ngAfterViewInit (around lines 14576-14590) schedules a setTimeout outside Angular when the host button has no text.
    • The callback assigns localized text to this.host.text.
    • ToolbarToolBase.ngOnDestroy only unsubscribes its click subscription; it does not cancel the timeout or guard its callback against destruction.
  • @progress/kendo-angular-toolbar/fesm2022/progress-kendo-angular-toolbar.mjs
    • The text setter (around line 2840) calls setTextDisplayMode.
    • setTextDisplayMode (around line 3162) registers afterNextRender with the button's injector. This fails if that injector has already been destroyed.

The original application uses the same base behavior through Add, Save, and Cancel toolbar tools. The standalone reproduction needs only the Add tool.

Suggested fix

Tie the pending text-initialization timeout to the directive lifetime: cancel it on destruction and/or prevent its callback from updating a destroyed host. Retain the normal localized default text behavior for live components.

Please add a regression test covering destruction of both the grid fixture and its environment injector before the pending timeout executes.

Verification

https://stackblitz.com/edit/stackblitz-starters-pa5nsfho

The attached minimal project was built successfully and run in headless Chrome. Automated browser checks confirmed:

  • Explicit-text control: zero uncaught errors.
  • Missing-text reproduction: NG0205, with afterNextRender, setTextDisplayMode, and the text setter in the stack.
0 comments