-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
regression "Cannot read property 'registerOnChange' of null at cleanUpControl" / "Error during cleanup of component" #40521
Comments
Error during cleanup of component
Error during cleanup of component
Here's the full stacktrace:
Notice how this uses ViewEngine, not Ivy, but that may not be relevant. |
PR angular#39235 introduced additional cleanup logic for form controls and directives. The cleanup logic relies on the presence of ControlValueAccessor instances on FormControlName and FormControl directives. In general these fields are present and there are also checks to make sure that the mentioned directive instances are created with CVAs. However some scenarios (primarily tests) may invoke the logic in a way that the directive instance would not be fully initialized, thus causing CVA to be absent. As a result, the cleanup logic fails while trying to call some methods on associated CVA instances. This commit updates the cleanup logic to take into account the situation when CVA is not present. Fixes angular#40521.
Hi @satanTime, thanks for reporting the issue. PR #39235 (changes were released in v11.1.0) introduced additional cleanup logic for form controls and directives. This cleanup logic relies on the fact that This is unlikely to happen in real scenarios (i.e. in an app on a page), but some specific use-cases in tests might cause the error to happen. So I've created a PR #40526 to make the cleanup logic more resilient to this type of scenarios. Thank you. |
Hi. Totally agree. We have a lib for testing which contains a couple of tests to ensure that it fails in the same way as angular does, but not sure that someone would do something similar in a real project. Thank you and happy coding! |
Hi, We use a directive to add dynamic Form controls, then in |
Ah, here we go, my condolences. |
Thank you for your kindness and sympathy. |
Hi @akram1905, thanks for providing additional information. The mentioned PR #40526 is in the merge queue and the fix will be available in v11.1.1 later this week.
The code that was there before in Thank you. |
…#40526) PR #39235 introduced additional cleanup logic for form controls and directives. The cleanup logic relies on the presence of ControlValueAccessor instances on FormControlName and FormControl directives. In general these fields are present and there are also checks to make sure that the mentioned directive instances are created with CVAs. However some scenarios (primarily tests) may invoke the logic in a way that the directive instance would not be fully initialized, thus causing CVA to be absent. As a result, the cleanup logic fails while trying to call some methods on associated CVA instances. This commit updates the cleanup logic to take into account the situation when CVA is not present. Fixes #40521. PR Close #40526
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
🐞 bug report
Affected Package
@angular/core/testing v11.1.0
Is this a regression?
Yes, the previous version in which this bug was not present was: v11.0.9
Description
tests for reactive forms without value accessor fail in clean up.
🔬 Minimal Reproduction
https://codesandbox.io/s/twilight-thunder-tbl3d?file=/src/test.spec.ts (open console)
change angular to 11.0.9 to see that error isn't present: https://take.ms/wuPcy
🔥 Exception or Error
which is caused by
🌍 Your Environment
Angular Version:
The text was updated successfully, but these errors were encountered: