diff --git a/packages/core/src/application/application_ref.ts b/packages/core/src/application/application_ref.ts
index 11fac6828f3..a79ab74e3e4 100644
--- a/packages/core/src/application/application_ref.ts
+++ b/packages/core/src/application/application_ref.ts
@@ -623,7 +623,6 @@ export class ApplicationRef {
private tickImpl = (): void => {
(typeof ngDevMode === 'undefined' || ngDevMode) && warnIfDestroyed(this._destroyed);
if (this._runningTick) {
- profiler(ProfilerEvent.ChangeDetectionEnd);
throw new RuntimeError(
RuntimeErrorCode.RECURSIVE_APPLICATION_REF_TICK,
ngDevMode && 'ApplicationRef.tick is called recursively',
@@ -662,11 +661,8 @@ export class ApplicationRef {
let runs = 0;
while (this.dirtyFlags !== ApplicationRefDirtyFlags.None && runs++ < MAXIMUM_REFRESH_RERUNS) {
profiler(ProfilerEvent.ChangeDetectionSyncStart);
- try {
- this.synchronizeOnce();
- } finally {
- profiler(ProfilerEvent.ChangeDetectionSyncEnd);
- }
+ this.synchronizeOnce();
+ profiler(ProfilerEvent.ChangeDetectionSyncEnd);
}
if ((typeof ngDevMode === 'undefined' || ngDevMode) && runs >= MAXIMUM_REFRESH_RERUNS) {
diff --git a/packages/core/src/render3/instructions/change_detection.ts b/packages/core/src/render3/instructions/change_detection.ts
index 8ea5429baee..b0cfbab698c 100644
--- a/packages/core/src/render3/instructions/change_detection.ts
+++ b/packages/core/src/render3/instructions/change_detection.ts
@@ -426,11 +426,9 @@ function detectChangesInComponent(
profiler(ProfilerEvent.ComponentStart);
const componentView = getComponentLViewByIndex(componentHostIdx, hostLView);
- try {
- detectChangesInViewIfAttached(componentView, mode);
- } finally {
- profiler(ProfilerEvent.ComponentEnd, componentView[CONTEXT] as any as {});
- }
+ detectChangesInViewIfAttached(componentView, mode);
+
+ profiler(ProfilerEvent.ComponentEnd, componentView[CONTEXT] as any as {});
}
/**
@@ -553,11 +551,8 @@ function processHostBindingOpCodes(tView: TView, lView: LView): void {
setBindingRootForHostBindings(bindingRootIndx, directiveIdx);
const context = lView[directiveIdx];
profiler(ProfilerEvent.HostBindingsUpdateStart, context);
- try {
- hostBindingFn(RenderFlags.Update, context);
- } finally {
- profiler(ProfilerEvent.HostBindingsUpdateEnd, context);
- }
+ hostBindingFn(RenderFlags.Update, context);
+ profiler(ProfilerEvent.HostBindingsUpdateEnd, context);
}
}
} finally {
diff --git a/packages/core/src/render3/instructions/render.ts b/packages/core/src/render3/instructions/render.ts
index 9449d6d38a0..88ccf7a3f2a 100644
--- a/packages/core/src/render3/instructions/render.ts
+++ b/packages/core/src/render3/instructions/render.ts
@@ -43,11 +43,9 @@ export function renderComponent(hostLView: LView, componentHostIdx: number) {
profiler(ProfilerEvent.ComponentStart);
- try {
- renderView(componentTView, componentView, componentView[CONTEXT]);
- } finally {
- profiler(ProfilerEvent.ComponentEnd, componentView[CONTEXT] as any as {});
- }
+ renderView(componentTView, componentView, componentView[CONTEXT]);
+
+ profiler(ProfilerEvent.ComponentEnd, componentView[CONTEXT] as any as {});
}
/**
diff --git a/packages/core/test/acceptance/profiler_spec.ts b/packages/core/test/acceptance/profiler_spec.ts
index 91495216ff3..ccb9dc2607c 100644
--- a/packages/core/test/acceptance/profiler_spec.ts
+++ b/packages/core/test/acceptance/profiler_spec.ts
@@ -492,117 +492,6 @@ describe('profiler', () => {
).toBeTrue();
});
- it('should capture child component creation events when a template error occurs', () => {
- @Component({selector: 'my-child', template: '{{ error() }}'})
- class ChildComponent {
- constructor() {
- throw new Error('Simulated error');
- }
- }
- @Component({selector: 'my-comp', imports: [ChildComponent], template: ''})
- class MyComponent {}
-
- expect(() => TestBed.createComponent(MyComponent)).toThrow();
-
- expect(p.hasEvents(ProfilerEvent.ComponentStart, ProfilerEvent.ComponentEnd)).toBeTrue();
- });
-
- it('should capture child component change detection events when a template error occurs', () => {
- @Component({selector: 'my-child', template: '{{ error() }}'})
- class ChildComponent {
- error() {
- throw new Error('Simulated error');
- }
- }
- @Component({selector: 'my-comp', imports: [ChildComponent], template: ''})
- class MyComponent {}
-
- const fixture = TestBed.createComponent(MyComponent);
-
- p.clearEvents();
-
- expect(() => fixture.detectChanges(false)).toThrow();
-
- expect(p.hasEvents(ProfilerEvent.ComponentStart, ProfilerEvent.ComponentEnd)).toBeTrue();
- });
-
- it('should capture child component change detection events when a template error occurs', () => {
- @Component({selector: 'my-child', template: '{{ error() }}'})
- class ChildComponent {
- error() {
- throw new Error('Simulated error');
- }
- }
- @Component({selector: 'my-comp', imports: [ChildComponent], template: ''})
- class MyComponent {}
-
- TestBed.createComponent(MyComponent);
-
- p.clearEvents();
-
- expect(() => TestBed.tick()).toThrow();
- expect(p.events).toEqual([
- ProfilerEvent.ChangeDetectionStart,
- ProfilerEvent.ChangeDetectionSyncStart,
- ProfilerEvent.ComponentStart,
- ProfilerEvent.TemplateUpdateStart,
- ProfilerEvent.TemplateUpdateEnd,
- ProfilerEvent.ComponentStart,
- ProfilerEvent.TemplateUpdateStart,
- ProfilerEvent.TemplateUpdateEnd,
- ProfilerEvent.ComponentEnd,
- ProfilerEvent.ComponentEnd,
- ProfilerEvent.ChangeDetectionSyncEnd,
- ProfilerEvent.ChangeDetectionEnd,
- ]);
- });
-
- it('should capture host binding events when an error occurs', () => {
- @Component({selector: 'my-comp', host: {'[a]': 'error()'}, template: ''})
- class MyComponent {
- error() {
- throw new Error('Simulated error');
- }
- }
-
- const fixture = TestBed.createComponent(MyComponent);
-
- p.clearEvents();
-
- expect(() => fixture.detectChanges(false)).toThrow();
-
- expect(
- p.hasEvents(ProfilerEvent.HostBindingsUpdateEnd, ProfilerEvent.HostBindingsUpdateEnd),
- ).toBeTrue();
- });
-
- it('should capture symmetric tick events when incorrectly called recursively', () => {
- @Component({selector: 'my-comp', template: '{{ illegalTick() }}'})
- class MyComponent {
- illegalTick() {
- TestBed.tick();
- }
- }
-
- TestBed.createComponent(MyComponent);
- p.clearEvents();
-
- expect(() => TestBed.tick()).toThrow();
-
- expect(p.events).toEqual([
- ProfilerEvent.ChangeDetectionStart,
- ProfilerEvent.ChangeDetectionSyncStart,
- ProfilerEvent.ComponentStart,
- ProfilerEvent.TemplateUpdateStart,
- ProfilerEvent.ChangeDetectionStart,
- ProfilerEvent.ChangeDetectionEnd,
- ProfilerEvent.TemplateUpdateEnd,
- ProfilerEvent.ComponentEnd,
- ProfilerEvent.ChangeDetectionSyncEnd,
- ProfilerEvent.ChangeDetectionEnd,
- ]);
- });
-
it('should invoke a profiler when host bindings are evaluated', () => {
@Component({
selector: 'my-comp',
@@ -644,7 +533,7 @@ describe('profiler', () => {
template: `
@defer (on immediate) {
nothing to see here...
- }
+ }
`,
})
class MyComponent {}