stackblitz / webcontainer-core

Dev environments. In your web app.
https://webcontainers.io
MIT License
3.88k stars 160 forks source link

Nestjs app errors out if run in dev mode. #391

Closed logesh-freshworks closed 2 years ago

logesh-freshworks commented 2 years ago

Describe the bug

Tried running Nestjs app in dev mode in the terminal. Its throwing the following error. The port is in use it seems.

(node:25) UnhandledPromiseRejectionWarning: Error: listen EADDRINUSE: address already in use :::3000
(Use `node --trace-warnings ...` to show where the warning was created)
(node:25) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:25) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
^C

Link to the blitz that caused the error

https://stackblitz.com/edit/nestjs-typescript-starter-rwk8zd?file=src%2Fapp.service.ts&terminal=start

Steps to reproduce

  1. Create a nestjs app
  2. open the terminal
  3. Run npm install
  4. Run start:dev
  5. Do some changes
  6. See the error in terminal

Expected behavior

Should restart the dev server when changes are made.

Screenshots

No response

Platform

Browser name  = Chrome 
Full version  = 95.0.4638.69
Major version = 95
navigator.appName = Netscape
navigator.userAgent = Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36
performance.memory = {
  "totalJSHeapSize": 111464709,
  "usedJSHeapSize": 105855925,
  "jsHeapSizeLimit": 4294705152
}
Hash = d83b9b15484f32317787d8c7cc41da5651102bdc

Additional context

No response

MarkPieszak commented 2 years ago

So I got it to work actually!

I opened the stackblitz, and in the terminal did ctrl-c to stop the process right away, and manually ran npm install && npm run start:dev and it worked.

image

@logesh-freshworks Did you make sure to ctrl-c and stop the process? Maybe you opened a new terminal and that previous npm start production process is still running?

MarkPieszak commented 2 years ago

Also @sulco @EricSimons, is it possible to have the project run npm install && npm run start:dev by default

(instead of npm install && npm start) ?

This way someone can see those real-time changes if they adjust one of the files!

logesh-freshworks commented 2 years ago

@MarkPieszak I did not run two terminals. I stopped the sever by hitting ctrl+c and tried running the dev server again. Still I had that error. Just now when I refreshed the page and tried again with npm start:dev command and made some changes , I got this error

Screenshot 2021-11-09 at 12 40 52 AM

logesh-freshworks commented 2 years ago

Here is a vidyard recording link

https://share.vidyard.com/watch/X3QAjPitn8HgKFkuJCuFk9?

MarkPieszak commented 2 years ago

Ahh you're right, now I'm seeing it strangely! Same error 🤔 That's odd it was working for a moment there!

image

This of course crashed the process, and now when trying to run again I get that 3000 port in use error, since it must have not stopped properly.

image

SamVerschueren commented 2 years ago

Thank you all for all the information! Changing the start command to be start:dev is an easy one on our side for sure. But as you guys already figured out, it doesn't work right now because the lack of the ps command. We should really add this to improve the DX for Nest.js in StackBlitz.

So let's make this happen!

web-dave commented 2 years ago

I checked this feature yesterday during my livestream. All my chat was very exited. here is the recording of the stream (German). https://www.twitch.tv/webdave_de/schedule?vodID=1200707528 Maybe there are further informations.

d3lm commented 2 years ago

Closing this issue as it doesn't seem to be an issue anymore. Also we have just shipped the ps command 🎉 If it does appear to be still a problem we can open a new issue.