Skip to content

fix(@angular/build): resolve "Controller is already closed" error in Karma #30653

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

Merged
merged 3 commits into from
Jul 8, 2025

Conversation

alan-agius4
Copy link
Collaborator

@alan-agius4 alan-agius4 commented Jul 4, 2025

This issue stems from the Some of your tests did a full page reload error, which occurs because karmaOptions.client.clearContext is set to true when singleRun is false, even though Karma is running in watch mode. Previously, the watch flag was configured inconsistently across multiple locations, leading to misalignment.

Closes #30506

@alan-agius4 alan-agius4 requested a review from jkrems July 4, 2025 10:21
@alan-agius4 alan-agius4 added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release labels Jul 4, 2025
@angular-robot angular-robot bot added the area: docs Related to the documentation label Jul 4, 2025
@alan-agius4 alan-agius4 force-pushed the karma-options branch 6 times, most recently from 9d404a8 to ef6092c Compare July 4, 2025 13:34
@alan-agius4 alan-agius4 added target: rc This PR is targeted for the next release-candidate and removed target: patch This PR is targeted for the next patch release labels Jul 4, 2025
@alan-agius4 alan-agius4 force-pushed the karma-options branch 3 times, most recently from 6bb0cf1 to 4673259 Compare July 5, 2025 13:27
@alan-agius4 alan-agius4 force-pushed the karma-options branch 2 times, most recently from f38af30 to 9bee394 Compare July 7, 2025 11:23
@@ -229,7 +229,8 @@
},
"watch": {
"type": "boolean",
"description": "Run build when files change."
"description": "Re-run tests when source files change.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double-checking: Was it ever a thing that the karma builder would default to non-watching outside of TTY?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No.

@@ -44,7 +44,7 @@
},
"watch": {
"type": "boolean",
"description": "Run build when files change."
"description": "Re-run tests when source files change. Defaults to `false` in TTY environments and `true` otherwise."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the default flipped here? I assume we do watch in TTY environments and don't outside of them? (Ref https://nodejs.org/api/tty.html#tty)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant false in non-TTY.

…Karma This issue stems from the `Some of your tests did a full page reload` error, which occurs because `karmaOptions.client.clearContext` is set to `true` when `singleRun` is `false`, even though Karma is running in watch mode. Previously, the `watch` flag was configured inconsistently across multiple locations, leading to misalignment. Closes angular#30506
Descriptions for the "watch" option where not clear.
…lders This ensures a cleaner and easier to follow code and also avoid having the fix bugs in multiple places.
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jul 8, 2025
@alan-agius4 alan-agius4 merged commit b160819 into angular:main Jul 8, 2025
31 checks passed
@alan-agius4 alan-agius4 deleted the karma-options branch July 8, 2025 06:44
@alan-agius4
Copy link
Collaborator Author

The changes were merged into the following branches: main, 20.1.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: merge The PR is ready for merge by the caretaker area: @angular/build area: docs Related to the documentation target: rc This PR is targeted for the next release-candidate
2 participants