-
Notifications
You must be signed in to change notification settings - Fork 395
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
getting EADDRINUSE
error when using start with watch mode with an async beforeApplicationShutdown
#1614
Comments
Would you like to create a PR to address this issue? |
I don't know how to fix that yet |
I guess this is beyond demo.mp4And this is related with #1487 So I believe that if we manage to fix that one, we'll fix this issue accordingly. |
I am not sure, but looks like it is related to how nest starts typescript, it just not wait process stop at all, even if you start npm run start you will see same behaviour |
It may not be directly related but I was experiencing this issue ( Changing the port I was using didn't help but what did seem to help was changing the way I was setting up my WORKDIR and COPY commands. Changing from something like this (which based on the image I'm using set the user to
to something like this:
Before making this change, my watch command failed after every single file change (which caused me to have to compose up again every time); and after making this change it has not failed at all so far. |
I was facing the same issue. In my case, it was caused by the shutdown hook suggested here. Once I removed the code, the problem was gone. By reading the docs, I've found that I need to update the bootstrap file. Now the problem is gone. That won't solve the issue in the OP, but it may still provide some lead. |
I did some digging into this one. Some observations, see if this sounds accurate:
UPDATE: Here's the change master...jleverenz:nest-cli:fix-cli-restart |
Same here, on WSL Ubuntu |
When running on Linux/WSL, `nest start --watch` does not wait the app to shutdown on restart. That leads to two instances of application running simultaneously, especially if it has async shutdown hooks. That commit fixes that adding an option to disable shell mode when spawning child processes so then app will completely shutdown first and only then started again. Thanks @jleverenz for the investigation (nestjs#1614 (comment)) and solution idea fixes nestjs/nest-cli/1614
Let's track this here #2522 |
Is there an existing issue for this?
Current behavior
when we have an async
beforeApplicationShutdown
that takes too long to resolve,nest start --watch
doesn't kill all the processes properly after file changes, which leads to anEADDRINUSE: address already in use
errorissue_demo.mp4
Minimum reproduction code
https://gitlab.com/micalevisk/nestjs-cli-issue-1614
Steps to reproduce
git clone https://gitlab.com/micalevisk/nestjs-cli-issue-1614 cd nestjs-cli-issue-1614
npm ci
npm run start:dev
Expected behavior
nestjs CLI should kill all processes before restarting the app
Package version
8.2.x
9.2.x - using
forceCloseConnections: true
doesn't fixes this10.0.3
NestJS version
8.4.x
9.3.x
10.0.3
Node.js version
16.14.2
In which operating systems have you tested?
The text was updated successfully, but these errors were encountered: