The CLI and app-scripts may not be cleanly shutting down servers (http, websocket, etc?) when Node exits via Ctrl+C.
@janpio
位 ionic serve
> ionic-app-scripts serve --address 0.0.0.0 --port 8101 --livereload-port 35729 --dev-logger-port 53703 --nobrowser
[app-scripts] [23:12:03] ionic-app-scripts 3.1.8
[app-scripts] [23:12:03] watch started ...
[app-scripts] [23:12:03] build dev started ...
[app-scripts] events.js:183
[app-scripts] throw er; // Unhandled 'error' event
[app-scripts] ^
[app-scripts]
[app-scripts] Error: listen EADDRINUSE :::53703
[app-scripts] at Object._errnoException (util.js:1022:11)
[app-scripts] at _exceptionWithHostPort (util.js:1044:20)
[app-scripts] at Server.setupListenHandle [as _listen2] (net.js:1367:14)
[app-scripts] at listenInCluster (net.js:1408:12)
[app-scripts] at Server.listen (net.js:1492:7)
[app-scripts] at new WebSocketServer (C:\Projects\<omitted>\node_modules\ws\lib\WebSocketServer.js:77:20)
[app-scripts] at Object.createNotificationServer (C:\Projects\<omitted>\node_modules\@ionic\app-scripts\dist\dev-server\notification-server.js:66:15)
[app-scripts] at C:\Projects\<omitted>\node_modules\@ionic\app-scripts\dist\serve.js:47:31
[app-scripts] at <anonymous>
[app-scripts] at process._tickCallback (internal/process/next_tick.js:188:7)
@janpio I'm not sure why some servers aren't shut down properly sometimes. We're doing everything on our end according to best practices of node. And when the process shuts down, everything should shut down as well.
In any case, I found an issue specifically with ionic-angular's serve that I fixed. A new RC is coming soon and the error that I pasted above should be a thing of the past.
Will check when released.
@janpio rc.2 is out with the fix for ionic-angular
Is the fix to work around the issue to increase the port if the default one is still blocked?
C:\Projects
位 npm install -g ionic@rc
C:\Program Files\nodejs\ionic -> C:\Program Files\nodejs\node_modules\ionic\bin\ionic
+ [email protected]
added 55 packages, removed 1 package and updated 9 packages in 31.195s
C:\Projects\Ionic Demo Projects\ionic-4-test (master -> origin)
位 ionic serve
> ng serve --host=0.0.0.0 --port=8100
[ng]
[ng] @angular/[email protected] requires typescript@'>=2.4.2 <2.7.0' but 2.7.2 was found instead.
[ng] Using this version can result in undefined behaviour and difficult to debug problems.
[ng]
[ng] Please run the following command to install a compatible version of TypeScript.
[ng]
[ng] npm install typescript@'>=2.4.2 <2.7.0'
[ng]
[ng] To disable this warning run "ng set warnings.typescriptMismatch=false".
[ng]
[OK] Development server running!
Local: http://localhost:8100
External: http://172.28.123.113:8100, http://169.254.80.80:8100, http://172.16.80.1:8100, http://192.168.56.1:8100,
http://192.168.119.2:8100, http://192.168.240.1:8100, http://192.168.17.1:8100, http://192.168.178.34:8100
DevApp: ionic4Test@8100 on LenovoX1
[INFO] Browser window opened to http://localhost:8100!
[ng] Date: 2018-04-12T13:28:03.676Z
[ng] Hash: e837ee4487364d6e0b8f
[ng] Time: 46451ms
[ng] chunk {inline} inline.bundle.js (inline) 3.85 kB [entry] [rendered]
[ng] chunk {main} main.bundle.js (main) 26 kB [initial] [rendered]
[ng] chunk {polyfills} polyfills.bundle.js (polyfills) 556 kB [initial] [rendered]
[ng] chunk {styles} styles.bundle.js (styles) 47.8 kB [initial] [rendered]
[ng] chunk {vendor} vendor.bundle.js (vendor) 9.72 MB [initial] [rendered]
[ng] webpack: Compiled successfully.
C:\Projects\Ionic Demo Projects\ionic-4-test (master -> origin)
位 ionic serve
> ng serve --host=0.0.0.0 --port=8101
[ng]
[ng] @angular/[email protected] requires typescript@'>=2.4.2 <2.7.0' but 2.7.2 was found instead.
[ng] Using this version can result in undefined behaviour and difficult to debug problems.
[ng]
[ng] Please run the following command to install a compatible version of TypeScript.
[ng]
[ng] npm install typescript@'>=2.4.2 <2.7.0'
[ng]
[ng] To disable this warning run "ng set warnings.typescriptMismatch=false".
[ng]
[OK] Development server running!
Local: http://localhost:8101
External: http://172.28.123.113:8101, http://169.254.80.80:8101, http://172.16.80.1:8101, http://192.168.56.1:8101,
http://192.168.119.2:8101, http://192.168.240.1:8101, http://192.168.17.1:8101, http://192.168.178.34:8101
DevApp: ionic4Test@8101 on LenovoX1
[INFO] Browser window opened to http://localhost:8101!
[ng] webpack: wait until bundle finished: /
[ng] Date: 2018-04-12T13:29:30.016Z
[ng] Hash: e837ee4487364d6e0b8f
[ng] Time: 29051ms
[ng] chunk {inline} inline.bundle.js (inline) 3.85 kB [entry] [rendered]
[ng] chunk {main} main.bundle.js (main) 26 kB [initial] [rendered]
[ng] chunk {polyfills} polyfills.bundle.js (polyfills) 556 kB [initial] [rendered]
[ng] chunk {styles} styles.bundle.js (styles) 47.8 kB [initial] [rendered]
[ng] chunk {vendor} vendor.bundle.js (vendor) 9.72 MB [initial] [rendered]
[ng] webpack: Compiled successfully.
@janpio The EADDRINUSE error is the fix I was referring to. I'm still unsure why on _some_ Windows machines, it doesn't properly shut down the server. At least it's not erroring for now.
Still happening here on Windows 10. It's an Ionic v3 project, but I've heard that using the v4 RC CLI shouldn't interfere.
cli packages: (C:\Users\vinicius\AppData\Roaming\npm\node_modules)
@ionic/cli-utils : 2.0.0-rc.6
ionic (Ionic CLI) : 4.0.0-rc.6
global packages:
cordova (Cordova CLI) : 7.1.0
local packages:
@ionic/app-scripts : 3.1.8
Cordova Platforms : android 6.3.0 browser 5.0.3 ios 4.5.4
Ionic Framework : ionic-angular 3.9.2
System:
NodeJS : v8.11.2
npm : 5.6.0
OS : Windows 10
Environment Variables:
ANDROID_HOME : not set
EDIT: Using the v4 CLI does interfere. Going back to the normal v3 one solved this issue for me.
I'm going to close this. I've done a bit of work ensuring to kill subprocesses (so I think RC.7 will be much better):
But, I think any other sporadic issues may be due to Node not working quite as perfectly on Windows as other platforms. I know the Node team is focusing on making this better every day.
Any specific issues related to the Ionic CLI not cleaning up after itself with Ctrl-C can be reported in new issues. I'd be happy to take a look.
I think @vadost encountered this issue again in this issue: https://github.com/ionic-team/ionic-cli/issues/3387
Closing in favor of https://github.com/ionic-team/ionic-cli/issues/3401
Most helpful comment
@janpio I'm not sure why some servers aren't shut down properly sometimes. We're doing everything on our end according to best practices of node. And when the process shuts down, everything should shut down as well.
In any case, I found an issue specifically with
ionic-angular's serve that I fixed. A new RC is coming soon and the error that I pasted above should be a thing of the past.