Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add debug context details to ExpressionChangedAfterItHasBeenCheckedError message #16340

Closed
schmuli opened this issue Apr 26, 2017 · 2 comments
Closed
Labels
area: core Issues related to the framework runtime

Comments

@schmuli
Copy link

schmuli commented Apr 26, 2017

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[x] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior
When an ExpressionChangedAfterItHasBeenCheckedError is displayed in the Browser console, or in a Karma reporter, no information about which component and property caused the error to occur.

Desired behavior
Include the information about which component and property caused the error in the Error's message, seeing as the data already exists in the Debug Context which is included in the error too.

Minimal reproduction of the problem with instructions
Below is the first few lines printed by the karma-mocha-reporter when such an error occurs in a unit-test:

Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'undefined'. Current value: 'DATE'.
    at viewDebugError (node_modules/@angular/core/bundles/core.umd.js:8611:32) [angular]
    at expressionChangedAfterItHasBeenCheckedError (node_modules/@angular/core/bundles/core.umd.js:8589:12) [angular]
    at checkBindingNoChanges (node_modules/@angular/core/bundles/core.umd.js:8753:15) [angular]
    at checkNoChangesNodeInline (node_modules/@angular/core/bundles/core.umd.js:12187:9) [angular]
    at checkNoChangesNode (node_modules/@angular/core/bundles/core.umd.js:12155:9) [angular]

What is the motivation / use case for changing the behavior?
Since the error can be caused by any component in the component tree, even when testing a specific component that contains child components, it is very difficult to pinpoint the actual cause, without having to have to resort to debugging the Angular code to catch the actual error instance.

Please tell us about your environment:

  • Angular version: 4.0.3
  • Browser: [all]
  • Language: [all]
  • Node (for AoT issues): node --version = 7.7.3
@matsko matsko added the area: core Issues related to the framework runtime label May 3, 2017
@tbosch
Copy link
Contributor

tbosch commented May 3, 2017

Angular supports source maps now. The error is logged from the place in the template that represents the element in which the error occurred.

AFAIK, this is a limitation of karma to not be able to use source maps (see e.g. karma-runner/karma#893), and also not being able to report the place from which a console.error originated.

Could you try to do the same using the debug view in karma, i.e. opening localhost:.../debug.html and then looking at the printed stack?

@tbosch tbosch closed this as completed May 3, 2017
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: core Issues related to the framework runtime
Projects
None yet
Development

No branches or pull requests

3 participants