Skip to content

NG0953 is an undocumented breaking behavior should be made optional #60110

Closed

Description

@sherlock1982

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

core

Is this a regression?

Yes

Description

Angular migrations guide (https://angular.dev/reference/migrations/outputs) suggests to migrate @Output decorators to output functions.
Though it brings in NG0953 errors if output is used after component is destroyed (see #19826 )

NG0953 is not anyhow mentioned in https://angular.dev/reference/migrations/outputs

There's no such page as https://angular.dev/errors/NG0953

Is is not easy to catch these errors after migration (especially if you do not expect them)

This error can be indication of a memory leak or a performance issue but doesn't cause any unexpected behavior

So what I can suggest:

  1. Improve documentation
  2. Make NG0953 configurable for example via extendedDiagnostics
  3. From my understanding NG0953 is also emitted in some other cases so probably this specific case should have a dedicated error?

Please provide a link to a minimal reproduction of the bug

No response

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: 19.1.7
Node: 22.11.0
Package Manager: yarn 4.6.0
OS: win32 x64

Angular: 19.1.6
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
... service-worker

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1901.7
@angular-devkit/build-angular   19.1.7
@angular-devkit/core            19.1.7
@angular-devkit/schematics      19.1.7
@angular/cdk                    19.1.4
@angular/cli                    19.1.7
@schematics/angular             19.1.7
rxjs                            7.8.2
typescript                      5.7.3
webpack                         5.98.0
zone.js                         0.15.0

Anything else?

P.S. For example unexpected crash on animation done event after component is destroyed (not trivial to resolve btw):

@HostListener('@flyInOut.done')
onAnimationEnd() {
      this.animationDone.emit(this.state);
}

Activity

  1. JeanMeche commented on Feb 26, 2025

    @JeanMeche
    Member

    Hi, extended diagnostics are a compile time feature while this error is a runtime one.

    The error is somehow correct and warns you that nothing was emmited.
    It is directly due to #19826 (the OutputEmitterRef is destroyed with DestroyRef).

  2. sherlock1982 commented on Feb 26, 2025

    @sherlock1982
    Author

    Should it become a warning instead of an unhandled error? Or somehow configurable? I saw that some runtime errors can be configured via injection parameters.
    I didn't expect my app to crash when I migrated from @Output decorators

  3. NateRadebaugh commented on Feb 26, 2025

    @NateRadebaugh
    Contributor

    The question is: "warns you that nothing was emitted" is a big deal and cause for concern/fixing, or whether it can be safely ignored?

    In the @Output decorators path, I imagine we have the same "issue" but no warning, and our apps are running as expected. I'm not sure the value added by "warning" via an explicit error, especially for the migration of existing code.

  4. added
    area: core
    area: docs
    on Feb 26, 2025
  5. modified the milestone: needsTriage on Feb 26, 2025
  6. sherlock1982 commented on Feb 26, 2025

    @sherlock1982
    Author

    It depends on the app and developer if it is a big deal or not.
    It might be a signal that something is not properly unsubscribed. So overall to me this is a good development warning but not a crash of course.

  7. JeanMeche commented on Mar 9, 2025

    @JeanMeche
    Member

    We discussed it with the team, we'll make it a warning in the next patch release.

  8. added a commit that references this issue on Mar 10, 2025
    30f6db3
  9. added a commit that references this issue on Mar 10, 2025
    e3afa24
  10. ahmad-moussawi commented on Mar 25, 2025

    @ahmad-moussawi

    I have a similar case, I have a popover that shows/disappears on mouse over, and the component emits a message when the data inside the popover loads, I see this error if the user hovers over the element and moves out quickly.

  11. adam-marshall commented on Apr 3, 2025

    @adam-marshall

    I'm still not sure making it a warning is desirable, unless I'm using it incorrectly?

    E.g. I have an overlay for selecting items, when you select an item the output emits, and the overlay is destroyed. Everything is working as expected, aside from the error/warning.

    Should there be some kind of option or implicit way of saying "I know what I'm doing, I expect this to emit once and then be destroyed"?

    Or is there another mechanism for handling this?

  12. angular-automatic-lock-bot commented on May 4, 2025

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  13. locked and limited conversation to collaborators on May 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: corearea: docs

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions