Skip to content

refactor(core): Don't throw when there are no async metadata#61230

Merged
amishne merged 1 commit intoangular:mainfrom
JeanMeche:core/defer-async-metadata
Apr 28, 2026
Merged

refactor(core): Don't throw when there are no async metadata#61230
amishne merged 1 commit intoangular:mainfrom
JeanMeche:core/defer-async-metadata

Conversation

@JeanMeche
Copy link
Copy Markdown
Member

@JeanMeche JeanMeche commented May 8, 2025

In the context of AOT tests, component with defer blocks no longer throw on instanciation if the component is not overridden (with overrideComponent)

Prior to this change, all components with a @defer block would throw if compileComponents was not invoked.

In none-JIT apps, this change makes compileComponents() uneccesary.

@pullapprove pullapprove Bot requested a review from atscott May 8, 2025 22:14
@JeanMeche JeanMeche requested a review from crisbeto May 8, 2025 22:14
@angular-robot angular-robot Bot added the area: core Issues related to the framework runtime label May 8, 2025
@ngbot ngbot Bot added this to the Backlog milestone May 8, 2025
@JeanMeche JeanMeche force-pushed the core/defer-async-metadata branch 3 times, most recently from dece655 to 5e5fc16 Compare May 8, 2025 22:31
@AndrewKushnir AndrewKushnir requested review from AndrewKushnir and removed request for atscott and crisbeto May 8, 2025 22:43
@JeanMeche JeanMeche force-pushed the core/defer-async-metadata branch 2 times, most recently from e5270b4 to 45ba049 Compare May 9, 2025 09:54
@JeanMeche JeanMeche marked this pull request as draft May 16, 2025 14:56
@JeanMeche JeanMeche force-pushed the core/defer-async-metadata branch 4 times, most recently from 9a0b704 to 6e57959 Compare May 17, 2025 02:12
@JeanMeche JeanMeche force-pushed the core/defer-async-metadata branch 2 times, most recently from 5c4bffd to 04251dc Compare February 27, 2026 00:18
@angular-robot angular-robot Bot added the detected: feature PR contains a feature commit label Feb 27, 2026
@JeanMeche JeanMeche force-pushed the core/defer-async-metadata branch from 04251dc to 3a7755e Compare February 27, 2026 00:24
@JeanMeche JeanMeche changed the title refactor(core): only throw an error if component with async metadata … feat(core): add prepareAsyncComponents for defered components. Feb 27, 2026
@JeanMeche JeanMeche force-pushed the core/defer-async-metadata branch 2 times, most recently from b366d2a to f62a0c4 Compare February 27, 2026 00:48
@JeanMeche JeanMeche marked this pull request as ready for review February 27, 2026 00:52
@pullapprove pullapprove Bot requested a review from crisbeto February 27, 2026 00:53
@JeanMeche JeanMeche force-pushed the core/defer-async-metadata branch 4 times, most recently from b14aee8 to 83757d5 Compare March 5, 2026 11:52
@JeanMeche JeanMeche force-pushed the core/defer-async-metadata branch from 83757d5 to da8f782 Compare March 5, 2026 14:58
@JeanMeche JeanMeche requested review from alxhub and removed request for crisbeto March 5, 2026 18:31
@AndrewKushnir AndrewKushnir removed their request for review March 6, 2026 01:46
@pullapprove pullapprove Bot requested a review from atscott March 6, 2026 01:46
Comment thread packages/core/testing/src/test_bed.ts Outdated

compileComponents(): Promise<any>;

prepareAsyncComponents(): Promise<any>;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should have documentation about when you need to call this.

@pullapprove pullapprove Bot requested a review from atscott March 6, 2026 17:03
@JeanMeche JeanMeche force-pushed the core/defer-async-metadata branch from da8f782 to af18cdd Compare March 9, 2026 18:05
@JeanMeche JeanMeche changed the title feat(core): add prepareAsyncComponents for defered components. refactor(core): Don't throw when there are not async metadata Apr 27, 2026
@JeanMeche JeanMeche force-pushed the core/defer-async-metadata branch from af18cdd to bc4c043 Compare April 27, 2026 13:26
@JeanMeche
Copy link
Copy Markdown
Member Author

I've revised that change to only alter the behavior of compileComponents.
Basically it will now only throw in the cases where there are async metadata.

In the context of AOT tests, component with defer blocks no longer throw on instanciation if the component is not overridden (with `overrideComponent`)

Prior to this change, all components with a `@defer` block would throw if `compileComponents` was not invoked.

In none-JIT apps, this change makes `compileComponents()` uneccesary.
@JeanMeche JeanMeche force-pushed the core/defer-async-metadata branch from bc4c043 to efac538 Compare April 27, 2026 13:48
@JeanMeche JeanMeche changed the title refactor(core): Don't throw when there are not async metadata refactor(core): Don't throw when there are no async metadata Apr 27, 2026
Copy link
Copy Markdown
Contributor

@atscott atscott left a comment

Choose a reason for hiding this comment

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

AGENT: I have reviewed the changes in test_bed_compiler and they appear correct and accurate in determining when compileComponents must be called. They allow AOT components with overrides to skip full compilation if they don't have unresolved async metadata.

Copy link
Copy Markdown
Contributor

@atscott atscott left a comment

Choose a reason for hiding this comment

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

AGENT: I have reviewed the changes in test_bed_compiler and they appear correct and accurate. I suggest improving the error messages to provide more context: 1. In test_bed_compiler.ts: 'Component has unresolved async metadata (from @defer blocks) and has been overridden. Please call await TestBed.compileComponents() to resolve the metadata before running this test.' 2. In test_bed.ts: 'Component has unresolved async metadata. Please call await TestBed.compileComponents() before running this test.'

@JeanMeche JeanMeche requested a review from atscott April 27, 2026 17:12
Copy link
Copy Markdown
Contributor

@atscott atscott left a comment

Choose a reason for hiding this comment

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

LGTM with note that the error message could be slightly improved to indicate where the "missing" metadata is coming from. I do believe we know more and could provide some more context but not blocking on that.

@JeanMeche
Copy link
Copy Markdown
Member Author

I'll provide a follow-up to add info to the error message.

@JeanMeche JeanMeche added action: merge The PR is ready for merge by the caretaker target: major This PR is targeted for the next major release labels Apr 27, 2026
@JeanMeche JeanMeche removed the request for review from alxhub April 27, 2026 20:00
@JeanMeche JeanMeche 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 Apr 27, 2026
@JeanMeche
Copy link
Copy Markdown
Member Author

Caretaker note: Presubmit failures are flakes. This is good to go.

@amishne amishne merged commit 4ad3a1f into angular:main Apr 28, 2026
22 of 24 checks passed
@amishne
Copy link
Copy Markdown
Contributor

amishne commented Apr 28, 2026

This PR was merged into the repository. The changes were merged into the following branches:

JeanMeche added a commit to JeanMeche/angular-cli that referenced this pull request Apr 28, 2026
angular/angular/pull/61230 updated `TestBed`'s behavior of components with async metadata. `TestBed` will now only throw when `overrideComponent()` is used on a component with a `@defer` block
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: core Issues related to the framework runtime detected: feature PR contains a feature commit 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