Skip to content

ng test hangs on SIGTERM in architect-command.ts #14118

@rcollette

Description

@rcollette

🐞 Bug report

Command (mark with an x)

- [ ] new
- [ ] build
- [ ] serve
- [x ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?

Possibly as of 7.1 or 7.2 branch. Was not seeing this behavior in CLI 1.2.6 but am seeing it in 7.3.7

Description

I am running lint, test and build simultaneously using the npm concurrently package. This has always worked in ngcli 1.2.6. When one of the tasks fails, concurrently issues a SIGTERM to the other tasks (fail fast), and the other tasks should shut down gracefully. In 7.3.7 this results in an error in ng test.

What is making this issue bad for me, is that when running this in a docker build (node:10.15.3-alpine) on a gitlab runner, the docker build just hangs, possibly in an infinite loop. The gitlab runner never releases.

When I run the demo from macOS, I do get back to a command prompt. I can't explain the discrepancy.

🔬 Minimal Reproduction

The basic reproduction steps are to use concurrently to run ng test and then process.exit(1) in another concurrently run task after the tests have started to run.

Please run npm run demo in this reproduction.
https://github.com/rcollette/ngcli-test-sigterm-demo

Keep in mind that the timeout in sigterm.js may need to be adjusted. On my machine 10s was enough time to get the tests started but before they finish.

🔥 Exception or Error

Output from an actual application build.


> concurrently --kill-others-on-fail "npm:lint" "npm:test:server" "npm:build:server" 

[test:server] 
[test:server] > [email protected] test:server /build
[test:server] > ng test --code-coverage --source-map --watch=false --progress=false
[test:server] 
[lint] 
[lint] > [email protected] lint /build
[lint] > ng lint --type-check
[lint] 
[build:server] 
[build:server] > [email protected] build:server /build
[build:server] > ng build --progress=false --prod --aot --source-map --es5-browser-support=false
[build:server] 
[lint] Linting "embark3-ui"...
[lint] 
[lint] ERROR: /build/src/app/shared/modals/entitlement/entitlement-modal.component.spec.ts:67:9 - Expected property shorthand in object literal ('{startDate}').
[lint] ERROR: /build/src/app/shared/modals/entitlement/entitlement-modal.component.spec.ts:68:9 - Expected property shorthand in object literal ('{endDate}').
[lint] 
[lint] Lint errors found in the listed files.
[lint] Linting "embark3-ui-e2e"...
[lint] 
[lint] 
[lint] All files pass linting.
[lint] npm ERR! code ELIFECYCLE
[lint] npm ERR! errno 1
[lint] npm ERR! [email protected] lint: `ng lint --type-check`
[lint] npm ERR! Exit status 1
[lint] npm ERR! 
npm ERR! Failed at the [email protected] lint script.
[lint] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[lint] 
[lint] npm ERR! A complete log of this run can be found in:
[lint] npm ERR!     /root/.npm/_logs/2019-04-09T20_26_17_967Z-debug.log
[lint] npm run lint exited with code 1
--> Sending SIGTERM to other processes..
[build:server] npm run build:server exited with code SIGTERM
--> Sending SIGTERM to other processes..
[test:server] Cannot read property 'success' of undefined
[test:server] TypeError: Cannot read property 'success' of undefined
[test:server]     at TestCommand.runSingleTarget (/build/node_modules/@angular/cli/models/packages/angular/cli/models/architect-command.ts:242:21)
    at process._tickCallback (internal/process/next_tick.js:68:7)

Output from reproduction example


US-RI026CO-MLT:sigterm richardcollette$ npm run demo
> [email protected] demo /Users/richardcollette/code/sigterm/sigterm
> concurrently --kill-others-on-fail "npm:lint" "npm:test" "npm:build" "npm:sigterm" 

[lint] 
[lint] > [email protected] lint /Users/richardcollette/code/sigterm/sigterm
[lint] > ng lint
[lint] 
[sigterm] 
[sigterm] > [email protected] sigterm /Users/richardcollette/code/sigterm/sigterm
[sigterm] > node sigterm.js
[sigterm] 
[build] 
[build] > [email protected] build /Users/richardcollette/code/sigterm/sigterm
[build] > ng build
[build] 
[test] 
[test] > [email protected] test /Users/richardcollette/code/sigterm/sigterm
[test] > ng test
[test] 
[lint] Linting "sigterm"...
[lint] 
[lint] 
[lint] All files pass linting.
[lint] Linting "sigterm-e2e"...
[lint] 
[lint] 
[lint] All files pass linting.
[lint] npm run lint exited with code 0
[test] 09 04 2019 23:50:38.660:WARN [karma]: No captured browser, open http://localhost:9877/
[test] 09 04 2019 23:50:38.664:INFO [karma-server]: Karma v4.0.1 server started at http://0.0.0.0:9877/
[test] 09 04 2019 23:50:38.664:INFO [launcher]: Launching browsers Chrome with concurrency unlimited
[test] 09 04 2019 23:50:38.674:INFO [launcher]: Starting browser Chrome
[sigterm] npm ERR! code ELIFECYCLE
[sigterm] npm ERR! errno 1
[sigterm] npm ERR! [email protected] sigterm: `node sigterm.js`
[sigterm] npm ERR! Exit status 1
npm ERR! 
[sigterm] npm ERR! Failed at the [email protected] sigterm script.
[sigterm] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[sigterm] 
[sigterm] npm ERR! A complete log of this run can be found in:
[sigterm] npm ERR!     /Users/richardcollette/.npm/_logs/2019-04-10T03_50_41_955Z-debug.log
[sigterm] npm run sigterm exited with code 1
--> Sending SIGTERM to other processes..
[build] npm run build exited with code SIGTERM
--> Sending SIGTERM to other processes..
[test] Cannot read property 'success' of undefined
[test] TypeError: Cannot read property 'success' of undefined
[test]     at TestCommand.runSingleTarget (/Users/richardcollette/code/sigterm/sigterm/node_modules/@angular/cli/models/packages/angular/cli/models/architect-command.ts:242:21)
[test]     at 
[test]     at process._tickCallback (internal/process/next_tick.js:188:7)
[test] npm run test exited with code SIGTERM
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] demo: `concurrently --kill-others-on-fail "npm:lint" "npm:test" "npm:build" "npm:sigterm" `
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] demo script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/richardcollette/.npm/_logs/2019-04-10T03_50_42_902Z-debug.log

🌍 Your Environment



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

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

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.13.8
@angular-devkit/build-angular     0.13.8
@angular-devkit/build-optimizer   0.13.8
@angular-devkit/build-webpack     0.13.8
@angular-devkit/core              7.3.8
@angular-devkit/schematics        7.3.8
@angular/cli                      7.3.8
@ngtools/webpack                  7.3.8
@schematics/angular               7.3.8
@schematics/update                0.13.8
rxjs                              6.3.3
typescript                        3.2.4
webpack                           4.29.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions