angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.77k stars 11.97k forks source link

Ctrl + C is not working dev-server with SSR #28336

Closed helloaliimran closed 3 weeks ago

helloaliimran commented 2 months ago

Command

serve

Is this a regression?

The previous version in which this bug was not present was

17

Description

The Ctrl+C command is not working to stop the application from the terminal.

Minimal Reproduction

I face this problem after updating angular material : ng update @angular/material

Exception or Error

No response

Your Environment

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

Angular CLI: 18.2.2
Node: 20.11.1
Package Manager: npm 9.8.1
OS: win32 x64

Angular: 18.2.2
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, material, platform-browser, platform-browser-dynamic
... platform-server, router, ssr

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1802.2
@angular-devkit/build-angular   18.2.2
@angular-devkit/core            18.2.2
@angular-devkit/schematics      18.2.2
@schematics/angular             18.2.2
rxjs                            7.8.1
typescript                      5.4.3
zone.js                         0.14.10

Anything else relevant?

No response

alan-agius4 commented 2 months ago

Are you using the vite based dev-server with ssr?

helloaliimran commented 2 months ago

vite based dev-server

no I am using simple VS Code compiler, and yes SSR is enable.

alan-agius4 commented 2 months ago

I'm not entirely sure what you mean by "VS Code compiler" in this context. You can either be using the Webpack or Vite based dev-server. Given that you're using SSR and encountering this issue, it's probable that you're working with the Vite dev server.

This is a known issue in this case, and is appears to be caused zone.js. As a workaround, you can use q + <enter>.

//cc @JiaLiPassion

anisabboud commented 1 month ago

Encountering the same issue for the past couple of weeks... (Angular 18.2 with Vite/SSR, WSL shell) ng serve => Ctrl + C sometimes works, and oftentimes stops working; especially when there's a console log.

Reproduction

  1. app.component.tsconstructor() { console.log('hello'); }
  2. ng serve
  3. Navigate to http://localhost:4200
  4. hello will be printed to the terminal, and after that Ctrl + C doesn't work image

Workarounds

Ctrl + D or q + <enter> work.

zygarios commented 1 month ago

I have the same problem

kuncevic commented 3 weeks ago

same problem here, initially thought taking place only in vs code but however same using external terminal. If you just serve and then ctrl+c all works, tho breaks after you console.log