Skip to content

fix(core): Ensure ComponentFixture does not duplicate error reporting…#60104

Closed
atscott wants to merge 1 commit intoangular:mainfrom
atscott:componentfixturerethrow
Closed

fix(core): Ensure ComponentFixture does not duplicate error reporting…#60104
atscott wants to merge 1 commit intoangular:mainfrom
atscott:componentfixturerethrow

Conversation

@atscott
Copy link
Copy Markdown
Contributor

@atscott atscott commented Feb 25, 2025

… from FakeAsync

When using fakeAsync, if errors happen inside the Angular zone, they are also handled by the fakeAsync machinery. Rethrowing errors from the NgZone.onError subscription is not appropriate in this case because it results in the error being thrown twice.

this._lastError = error;
return false; // Don't propagate error to parent zone.
private _resetLastErrorAndThrow(): void {
let error = this._lastError || this._uncaughtPromiseErrors[0];
this._uncaughtPromiseErrors.length = 0;
this._lastError = null;
throw error;
}

@atscott atscott assigned atscott and unassigned atscott Feb 25, 2025
@angular-robot angular-robot bot added the area: core Issues related to the framework runtime label Feb 25, 2025
@atscott atscott added area: testing Issues related to Angular testing features, such as TestBed target: major This PR is targeted for the next major release labels Feb 25, 2025
@ngbot ngbot bot added this to the Backlog milestone Feb 25, 2025
@atscott atscott added the requires: TGP This PR requires a passing TGP before merging is allowed label Feb 25, 2025
@pullapprove pullapprove bot removed the requires: TGP This PR requires a passing TGP before merging is allowed label Feb 25, 2025
… from FakeAsync

When using `fakeAsync`, if errors happen inside the Angular zone, they
are also handled by the fakeAsync machinery. Rethrowing errors from the
`NgZone.onError` subscription is not appropriate in this case because it
results in the error being thrown twice.

https://github.com/angular/angular/blob/db2f2d99c82aae52d8a0ae46616c6411d070b35e/packages/zone.js/lib/zone-spec/fake-async-test.ts#L783-L784
https://github.com/angular/angular/blob/db2f2d99c82aae52d8a0ae46616c6411d070b35e/packages/zone.js/lib/zone-spec/fake-async-test.ts#L473-L478
@atscott atscott force-pushed the componentfixturerethrow branch from 95251c3 to 7c3550c Compare February 25, 2025 23:50
@pullapprove pullapprove bot requested a review from JiaLiPassion February 25, 2025 23:51
@atscott
Copy link
Copy Markdown
Contributor Author

atscott commented Feb 26, 2025

Green TGP

@atscott atscott added the action: merge The PR is ready for merge by the caretaker label Feb 26, 2025
@atscott atscott removed the request for review from JiaLiPassion February 26, 2025 16:18
@pullapprove pullapprove bot requested a review from JiaLiPassion February 26, 2025 16:19
@atscott atscott added the merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note label Feb 26, 2025
@atscott
Copy link
Copy Markdown
Contributor Author

atscott commented Feb 26, 2025

caretaker note: current approvals are sufficient for merge and there is a green TGP.

@kirjs
Copy link
Copy Markdown
Contributor

kirjs commented Feb 26, 2025

This PR was merged into the repository by commit 962b59b.

The changes were merged into the following branches: main

@kirjs kirjs closed this in 962b59b Feb 26, 2025
@angular-automatic-lock-bot
Copy link
Copy Markdown

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 Mar 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: core Issues related to the framework runtime area: testing Issues related to Angular testing features, such as TestBed merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants