Skip to content

UnhandledPromiseRejectionWarning when compiling broken SCSS with aot=true #15240

@devoto13

Description

@devoto13

🐞 Bug report

Command (mark with an x)

- [x] build
- [x] serve

Is this a regression?

Not sure.

Description

ng serve does not handle invalid SCSS gracefully in AOT mode. See minimal reproduction for more details.

🔬 Minimal Reproduction

$ ng new --style scss test-app
$ ng serve --aot

Wait until it completes, then open src/app/app.component.scss and add any invalid code, like .rule (note missing brackets).

Observe UnhandledPromiseRejectionWarning in the terminal.

In JIT mode it gives a helpful error message instead:

ERROR in ./src/app/app.component.scss
Module build failed (from ./node_modules/sass-loader/lib/loader.js):

.rule
    ^
      Expected "{".
  ╷
1 │ .rule
  │      ^
  ╵

🔥 Exception or Error

(node:43977) UnhandledPromiseRejectionWarning: TypeError: Cannot destructure property `warnings` of 'undefined' or 'null'.
    at /Users/devoto13/Projects/trash/test-app/node_modules/@ngtools/webpack/src/resource_loader.js:81:23
    at /Users/devoto13/Projects/trash/test-app/node_modules/webpack/lib/Compiler.js:659:23
    at /Users/devoto13/Projects/trash/test-app/node_modules/webpack/lib/Compilation.js:1379:13
    at eval (eval at create (/Users/devoto13/Projects/trash/test-app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:12:1)
    at /Users/devoto13/Projects/trash/test-app/node_modules/@ngtools/webpack/src/resource_loader.js:70:39
    at processTicksAndRejections (internal/process/task_queues.js:85:5)

🌍 Your Environment

Angular CLI: 8.2.0
Node: 12.7.0
OS: darwin x64
Angular: 8.2.0
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.802.0
@angular-devkit/build-angular     0.802.0
@angular-devkit/build-optimizer   0.802.0
@angular-devkit/build-webpack     0.802.0
@angular-devkit/core              8.2.0
@angular-devkit/schematics        8.2.0
@ngtools/webpack                  8.2.0
@schematics/angular               8.2.0
@schematics/update                0.802.0
rxjs                              6.4.0
typescript                        3.5.3
webpack                           4.38.0

Anything else relevant?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions