Skip to content

SCSS partial error cached and not invalidated on fix during ng serve (esbuild) #32744

@Nvveen

Description

@Nvveen

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

No response

Description

When ng serve is running and a SCSS partial contains an error, fixing the partial does not clear the error. The dev server detects the file change and triggers a rebuild, but continues to show the original error from the partial. The only fix is restarting ng serve.
The error cache introduced in 5623c19 appears to not correctly invalidate when a partial is changed, specifically when the partial is imported transitively (partial → intermediary partial → component SCSS entry point).

Minimal Reproduction

  1. Have a SCSS partial imported transitively, e.g.:
    _brand.scss → imported by _variables.scss → imported by component SCSS files
  2. Introduce a syntax error in _brand.scss
  3. Observe the build error
  4. Fix the error in _brand.scss and save
  5. Observe that ng serve detects the change and rebuilds, but continues showing the original error

This doesn't always work, to reproduce, but most reliably by causing an error, fixing it and saving it before the dev server is done recompiling the SCSS.

Exception or Error

The cached error from _brand.scss persists across rebuilds until ng serve is restarted.

Additional observations:
- `stat` confirms the file mtime updates correctly on save
- `grep` confirms the fix is written to disk
- Introducing a TypeScript error after will show the TS error, but fixing it brings back the stale SCSS error
- The error references the partial correctly in the stack trace, ruling out a watcher issue
- The test added in 5623c19 only covers global styles, not transitively imported partials

Your Environment

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

Angular CLI       : 21.1.3
Angular           : 21.1.3
Node.js           : 22.17.0
Package Manager   : npm 10.9.2
Operating System  : linux x64

┌───────────────────────────────────┬───────────────────┬───────────────────┐
│ Package                           │ Installed Version │ Requested Version │
├───────────────────────────────────┼───────────────────┼───────────────────┤
│ @angular/animations               │ 21.1.3            │ ^21.1.1           │
│ @angular/build                    │ 21.1.3            │ ^21.1.1           │
│ @angular/cdk                      │ 21.1.3            │ ^21.1.1           │
│ @angular/cli                      │ 21.1.3            │ ^21.1.1           │
│ @angular/common                   │ 21.1.3            │ ^21.1.1           │
│ @angular/compiler                 │ 21.1.3            │ ^21.1.1           │
│ @angular/compiler-cli             │ 21.1.3            │ ^21.1.1           │
│ @angular/core                     │ 21.1.3            │ ^21.1.1           │
│ @angular/forms                    │ 21.1.3            │ ^21.1.1           │
│ @angular/platform-browser         │ 21.1.3            │ ^21.1.1           │
│ @angular/platform-browser-dynamic │ 21.1.3            │ ^21.1.1           │
│ @angular/router                   │ 21.1.3            │ ^21.1.1           │
│ @angular/service-worker           │ 21.1.3            │ ^21.1.1           │
│ rxjs                              │ 7.8.2             │ ^7.8.1            │
│ typescript                        │ 5.9.3             │ ^5.7.3            │
│ zone.js                           │ 0.16.0            │ ^0.16.0           │
└───────────────────────────────────┴───────────────────┴───────────────────┘

Anything else relevant?

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