Skip to content

dev server stops updating if the user saves while the HTML is in an invalid state #29907

Closed

Description

@Exac

Command

serve

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

19

Description

The following is in an empty project created via ng new with all defaults selected.
First I run the dev server and open my Chrome browser (clean install, no extensions installed).
I have the following code saved in my app.component.html:

<p><strong>foo</strong></p>

I delete the opening <strong> tag, and save (or my editor auto-saves, which makes this annoying).

<p>foo</strong></p>

In my terminal, I see the dev server has reported the problem:

Application bundle generation failed. [0.108 seconds]

✘ [ERROR] NG5002: Unexpected closing tag "strong". It may happen when the tag has already been closed by another tag. For more info see https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags [plugin angular-compiler]

    src/app/app.component.html:2:5:
      2 │   foo</strong>
        ╵      ~~~~~~~~~

  Error occurs in the template of component AppComponent.

    src/app/app.component.ts:7:15:
      7 │   templateUrl: './app.component.html',
        ╵                ~~~~~~~~~~~~~~~~~~~~~~

Oops! I add the opening tag back and save again:

<p><strong>foo</strong></p>

The dev server rebuilds, no errors this time.

Browser bundles     
Initial chunk files  | Names            |  Raw size
polyfills.js         | polyfills        |  90.20 kB | 
main.js              | main             |   2.20 kB | 
styles.css           | styles           |  95 bytes | 

                     | Initial total    |  92.50 kB

But my browser now displays this error:

TypeError: ɵgetOrCreateAngularServerApp is not a function
    at _AngularAppEngine.eval (/home/exac/WebstormProjects/get-or-create-angular-server-app-is-not-a-function/.angular/cache/19.2.4/get-or-create-angular-server-app-is-not-a-function/vite/deps_ssr/chunk-J6AJWQHP.js:11513:25)
    at Generator.next (<anonymous>)
    at fulfilled (/home/exac/WebstormProjects/get-or-create-angular-server-app-is-not-a-function/.angular/cache/19.2.4/get-or-create-angular-server-app-is-not-a-function/vite/deps_ssr/chunk-YHCV7DAQ.js:72:24)
    at _ZoneDelegate.invoke (/home/exac/WebstormProjects/get-or-create-angular-server-app-is-not-a-function/.angular/vite-root/get-or-create-angular-server-app-is-not-a-function/node_modules/zone.js/fesm2015/zone-node.js:369:28)
    at ZoneImpl.run (/home/exac/WebstormProjects/get-or-create-angular-server-app-is-not-a-function/.angular/vite-root/get-or-create-angular-server-app-is-not-a-function/node_modules/zone.js/fesm2015/zone-node.js:111:43)
    at eval (/home/exac/WebstormProjects/get-or-create-angular-server-app-is-not-a-function/.angular/vite-root/get-or-create-angular-server-app-is-not-a-function/node_modules/zone.js/fesm2015/zone-node.js:1221:40)
    at _ZoneDelegate.invokeTask (/home/exac/WebstormProjects/get-or-create-angular-server-app-is-not-a-function/.angular/vite-root/get-or-create-angular-server-app-is-not-a-function/node_modules/zone.js/fesm2015/zone-node.js:402:33)
    at ZoneImpl.runTask (/home/exac/WebstormProjects/get-or-create-angular-server-app-is-not-a-function/.angular/vite-root/get-or-create-angular-server-app-is-not-a-function/node_modules/zone.js/fesm2015/zone-node.js:159:47)
    at drainMicroTaskQueue (/home/exac/WebstormProjects/get-or-create-angular-server-app-is-not-a-function/.angular/vite-root/get-or-create-angular-server-app-is-not-a-function/node_modules/zone.js/fesm2015/zone-node.js:581:35)

My browser's console logs:

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

And now my browser is stuck on the page displaying the error, and won't reload on any more changes.

As a developer, I expect the dev server to recover every time I save.

Apologies if this is a duplicate, or belongs in another repo (vite? another Angular repo?). I couldn't find a report exactly like this.

Minimal Reproduction

Environment: This happens when running the dev server directly on my development machine. I can't reproduce this in StackBlitz after saving ~20 times.

  1. Install a new Angular project using the defaults.
  2. Run ng serve
  3. Change app.component.html to <p><strong>foo</strong></p>
  4. Save and watch the dev server reload the page
  5. Change app.component.html to <p>foo</strong></p>. Save.
  6. Change app.component.html to <p><strong>foo</strong></p>. Save.
  7. See the error in the browser ɵgetOrCreateAngularServerApp is not a function, if it reloads properly, repeat steps 5 and 6 a few times until it doesn't reload.

Video

20250321-0523-21.7071165.mp4

Exception or Error

TypeError: ɵgetOrCreateAngularServerApp is not a function
    at _AngularAppEngine.eval (/home/exac/WebstormProjects/get-or-create-angular-server-app-is-not-a-function/.angular/cache/19.2.4/get-or-create-angular-server-app-is-not-a-function/vite/deps_ssr/chunk-J6AJWQHP.js:11513:25)
    at Generator.next (<anonymous>)
    at fulfilled (/home/exac/WebstormProjects/get-or-create-angular-server-app-is-not-a-function/.angular/cache/19.2.4/get-or-create-angular-server-app-is-not-a-function/vite/deps_ssr/chunk-YHCV7DAQ.js:72:24)
    at _ZoneDelegate.invoke (/home/exac/WebstormProjects/get-or-create-angular-server-app-is-not-a-function/.angular/vite-root/get-or-create-angular-server-app-is-not-a-function/node_modules/zone.js/fesm2015/zone-node.js:369:28)
    at ZoneImpl.run (/home/exac/WebstormProjects/get-or-create-angular-server-app-is-not-a-function/.angular/vite-root/get-or-create-angular-server-app-is-not-a-function/node_modules/zone.js/fesm2015/zone-node.js:111:43)
    at eval (/home/exac/WebstormProjects/get-or-create-angular-server-app-is-not-a-function/.angular/vite-root/get-or-create-angular-server-app-is-not-a-function/node_modules/zone.js/fesm2015/zone-node.js:1221:40)
    at _ZoneDelegate.invokeTask (/home/exac/WebstormProjects/get-or-create-angular-server-app-is-not-a-function/.angular/vite-root/get-or-create-angular-server-app-is-not-a-function/node_modules/zone.js/fesm2015/zone-node.js:402:33)
    at ZoneImpl.runTask (/home/exac/WebstormProjects/get-or-create-angular-server-app-is-not-a-function/.angular/vite-root/get-or-create-angular-server-app-is-not-a-function/node_modules/zone.js/fesm2015/zone-node.js:159:47)
    at drainMicroTaskQueue (/home/exac/WebstormProjects/get-or-create-angular-server-app-is-not-a-function/.angular/vite-root/get-or-create-angular-server-app-is-not-a-function/node_modules/zone.js/fesm2015/zone-node.js:581:35)

Your Environment

exac@DESKTOP-58AJUTF:~/WebstormProjects/get-or-create-angular-server-app-is-not-a-function$ ng version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 19.2.4
Node: 20.18.3
Package Manager: npm 10.8.2
OS: linux x64

Angular: 19.2.3
... common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1902.4
@angular-devkit/build-angular   19.2.4
@angular-devkit/core            19.2.4
@angular-devkit/schematics      19.2.4
@angular/cli                    19.2.4
@angular/ssr                    19.2.4
@schematics/angular             19.2.4
rxjs                            7.8.2
typescript                      5.7.3
zone.js                         0.15.0

Anything else relevant?

No response

Activity

  1. imaksp commented on Mar 21, 2025

    @imaksp
    Contributor

    I was having difficulty in reproducing this error on new app, good to see this, also if you make any new change in file like adding empty space it should recover.

  2. alan-agius4 commented on Mar 21, 2025

    @alan-agius4
    Collaborator

    @Exac, thank you for the detailed and insightful issue report!

  3. self-assigned this
    on Mar 21, 2025
  4. added a commit that references this issue on Mar 21, 2025
    98685f3
  5. added theissue type on Mar 21, 2025
  6. added a commit that references this issue on Mar 21, 2025
    32b1dcd
  7. added a commit that references this issue on Mar 21, 2025
    a8817a3
  8. angular-automatic-lock-bot commented on Apr 21, 2025

    @angular-automatic-lock-bot

    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.

  9. locked and limited conversation to collaborators on Apr 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions