Thanks to visit codestin.com
Credit goes to github.com

Skip to content

DestroyRef timing differs from ngOnDestroy #62182

Open
@theo-matzavinos

Description

@theo-matzavinos

Which @angular/* package(s) are the source of the bug?

core

Is this a regression?

No

Description

It seems that callbacks registered with DestroyRef run after the component is destroyed whereas the ngOnDestroy hook runs before. Is this a bug or undocumented behavior?

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/stackblitz-starters-2wrenhca?file=src%2Fmain.ts

Please provide the exception or error you saw

NG0953: Unexpected emit for destroyed `OutputRef`. The owning directive/component is destroyed.

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 20.0.0
Node: 20.19.1
Package Manager: npm 10.8.2
OS: linux x64

Angular: 20.0.0
... animations, build, cli, common, compiler, compiler-cli, core
... forms, platform-browser, router

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.2000.0
@angular-devkit/core         20.0.0
@angular-devkit/schematics   20.0.0
@schematics/angular          20.0.0
rxjs                         7.8.2
typescript                   5.8.2
zone.js                      0.15.0

Anything else?

No response

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