Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate clean shutdown of serve #3022

Closed
imhoffd opened this issue Mar 22, 2018 · 10 comments
Closed

Investigate clean shutdown of serve #3022

imhoffd opened this issue Mar 22, 2018 · 10 comments

Comments

@imhoffd
Copy link
Contributor

imhoffd commented Mar 22, 2018

The CLI and app-scripts may not be cleanly shutting down servers (http, websocket, etc?) when Node exits via Ctrl+C.

@imhoffd imhoffd added this to the CLI 4.0.0 milestone Mar 22, 2018
@imhoffd
Copy link
Contributor Author

imhoffd commented Mar 22, 2018

@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)

imhoffd added a commit that referenced this issue Mar 23, 2018
@imhoffd
Copy link
Contributor Author

imhoffd commented Mar 26, 2018

@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.

@imhoffd imhoffd closed this as completed Mar 26, 2018
@janpio
Copy link
Contributor

janpio commented Mar 26, 2018

Will check when released.

@imhoffd
Copy link
Contributor Author

imhoffd commented Apr 3, 2018

@janpio rc.2 is out with the fix for ionic-angular

@janpio
Copy link
Contributor

janpio commented Apr 12, 2018

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.

@imhoffd
Copy link
Contributor Author

imhoffd commented Apr 12, 2018

@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.

@vilanz
Copy link

vilanz commented May 23, 2018

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.

@imhoffd
Copy link
Contributor Author

imhoffd commented Jun 12, 2018

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.

@imhoffd
Copy link
Contributor Author

imhoffd commented Jul 26, 2018

I think @vadost encountered this issue again in this issue: #3387

@imhoffd imhoffd removed this from the CLI 4.0.0 milestone Jul 26, 2018
@imhoffd
Copy link
Contributor Author

imhoffd commented Jul 26, 2018

Closing in favor of #3401

@imhoffd imhoffd closed this as completed Jul 26, 2018
trsrm added a commit to powwowinc/ionic-app-scripts-tiny that referenced this issue Jan 2, 2019
3.1.9:
* fix(2889): fix build error with --prod
* fix(serve): start listening when watch is ready
* fix(live-server): update android platform path (ionic-team#1407)
* docs(changelog): 3.1.9

3.1.10:
* Update node-sass dependency (ionic-team#1435)
Updating node-sass dependency from 4.7.2 to 4.9.0 to make it works with node 10 on windows (build fail with ionic start)
* chore(package): bump deps (ionic-team#1421)
* chore(deps): no package lock
* chore(changelog): 3.1.10

3.1.11:
* fix(serve): fix EADDRINUSE issue with dev logger server
fixes ionic-team/ionic-cli#3368
fixes ionic-team/ionic-cli#1678
fixes ionic-team/ionic-cli#1830
fixes ionic-team/ionic-cli#1721
fixes ionic-team/ionic-cli#1866
fixes ionic-team/ionic-cli#1808
fixes ionic-team/ionic-cli#3022
* docs(changelog): 3.1.11 changes

3.2.0:
* feat(environments): configuration via process.env.VAR replacement (ionic-team#1471)
* fix(sass): remove PostCSS warning (ionic-team#1364)
This removes following warning:
Remove warning: Without `from` option PostCSS could generate wrong source map or do not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning
`from: the input file name (most runners set it automatically).`
Source: https://github.com/postcss/postcss
Fixes ionic-team#1359 #13763
ionic-team#1359
ionic-team/ionic-framework#13763
* fix(serve): use wss protocol for secure websocket when page is using https (ionic-team#1358)
* docs(changelog): 3.2.0

3.2.1:
* docs(readme): add note about existing declaration
addresses ionic-team/ionic-cli#3541
* chore(deps): update webpack to 3.12.0 (ionic-team#1477)
* chore(deps): bump node-sass to 4.9.3 to fix security warnings (ionic-team#1483)
* chore(deps): bump node-sass to 4.10.0 to fix security warnings (ionic-team#1493)
* docs(changelog): 3.2.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants