Skip to content

dev-server "recovers" from error loading wrong index.html #32161

@vokeit-gschuster

Description

@vokeit-gschuster

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

Don't known / other

Is this a regression?

No

Description

In a new project setup with "ng new my-project" the dev-server renders the given index.html from src/index.html
If then there's an error in the compilation, e.g. a provoked one in app.ts:

  constructor() {
        this.doesnotexist.bar();
  }

it shows the error, when it's fixed it returns to normal.

The "bug" occurs if there's also a public/index.html in place.
As long as there's no error it never gets loaded.
But as soon as there has been an error once the compiler "forgets" it should render src/index.html as starting point and then renders public/index.html until the whole dev-server gets restarted.
This even occurs when given the "architect > build > options > index" option, it is silently ignored as soon as there has been one error in the dev-server session.

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

In my case a totally blank page as there was a blank public/index.html left-over from previous tests.

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

┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package                   │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build            │ 21.0.3            │ ^21.0.2           │
│ @angular/cli              │ 21.0.3            │ ^21.0.2           │
│ @angular/common           │ 21.0.5            │ ^21.0.0           │
│ @angular/compiler         │ 21.0.5            │ ^21.0.0           │
│ @angular/compiler-cli     │ 21.0.5            │ ^21.0.0           │
│ @angular/core             │ 21.0.5            │ ^21.0.0           │
│ @angular/forms            │ 21.0.5            │ ^21.0.0           │
│ @angular/platform-browser │ 21.0.5            │ ^21.0.0           │
│ @angular/router           │ 21.0.5            │ ^21.0.0           │
│ rxjs                      │ 7.8.2             │ ~7.8.0            │
│ typescript                │ 5.9.3             │ ~5.9.2            │
│ vitest                    │ 4.0.16            │ ^4.0.8            │
└───────────────────────────┴───────────────────┴───────────────────┘

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions