Skip to content

[CLOSED] Unknown regression in angular 20.0.0 versus previous versions #61904

@LanderBeeuwsaert

Description

@LanderBeeuwsaert

Which @angular/* package(s) are the source of the bug?

compiler, core

Is this a regression?

Yes

Description

This code:

import {
  EnvironmentInjector,
  inject,
  Component,
  runInInjectionContext,
} from '@angular/core';

@Component({
  selector: 'app-root',
  template: `
    Welcome to Angular!
  `,
})
export class App {
  private readonly _injector: EnvironmentInjector = inject(EnvironmentInjector);

  constructor() {
    console.log('app start');

    setTimeout(async () => {
      try {
        return runInInjectionContext(this._injector, async () => {
          throw new Error('error');
        });
      } catch (e) {
        console.log('in Catch');
      }
    }, 200);
  }
}

in angular 20 this will trigger the angular error handler. In previous versions this did not happen.
The consequence of this is that you cannot choose to handle errors anymore that happen inside of the runInInjectionContext without that it triggers the error handler.
without

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw


Please provide the environment you discovered this bug in (run ng version)


Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions