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

Can not run fastify cli in watch mode with node inspector #200

Closed
pyxarez opened this issue Aug 27, 2019 · 14 comments
Closed

Can not run fastify cli in watch mode with node inspector #200

pyxarez opened this issue Aug 27, 2019 · 14 comments
Labels
good first issue Good for newcomers

Comments

@pyxarez
Copy link

pyxarez commented Aug 27, 2019

🐛 Bug Report

Cli is not working in --watch mode with node inspect on the board
It throws the following log: Starting inspector on 127.0.0.1:9230 failed: address already in use

To Reproduce

Steps to reproduce the behavior:

Paste your code here:

node --inspect-brk=9230 ./node_modules/.bin/fastify start --watch -l info -P app.js

Expected behavior

It should work in --watch mode with node inspect on the board

Your Environment

  • node version: 10
  • fastify version: >=2.0.0
  • os: Mac
@mcollina
Copy link
Member

This happens because we are forking the project: https://github.com/fastify/fastify-cli/blob/master/lib/watch/fork.js. We might want to do something about this, as it's a rather convenient feature.

Can you do the same with Nodemon for example? How do they implement/support it?

@pyxarez
Copy link
Author

pyxarez commented Aug 27, 2019

Can you do the same with Nodemon for example? How do they implement/support it?

I don't fully understand the question
Yea, I can try to do the same with nodemon, but it requires migrating from cli, making my own server.js and leads to loss of fastify-cli functionality like logging, default setup, etc.
It will look like this nodemon --inspect=9230 server.js

@mcollina
Copy link
Member

You answered the question! nodemon implements it via a --inspect flag. Would you like to send a PR that adds that to fastify-cli as well?

@mcollina mcollina added the good first issue Good for newcomers label Aug 27, 2019
@pyxarez
Copy link
Author

pyxarez commented Aug 27, 2019

Hmm, that's an interesting idea
Yeah, I can try to do that, but I'm new in fastify and I think it'll take some time
If you do not need super fast fix that's the task for me

@mcollina
Copy link
Member

Go ahead!

@xtx1130
Copy link
Contributor

xtx1130 commented Aug 29, 2019

I am sure child_process.fork() caused this, you need add options {execArgv: []} to cp.fork()

@pyxarez
Copy link
Author

pyxarez commented Aug 29, 2019

@xtx1130 , I tried you suggestion and it's actually work!
But will this not lead to errors in the case when we really want to use execArgv?

@pyxarez
Copy link
Author

pyxarez commented Aug 29, 2019

I admit that that's an internal usage of fork and there is no case when someone would like to parametrise that part from outisde

@gbertoncelli
Copy link
Contributor

gbertoncelli commented Aug 29, 2019

I'm going to make a PR of this if you want... I was able to manage that with execArgv parameter and adding a debug flag to the CLI.
image
I'm trying now to use the debug flag also without watch mode, but I'm working on that...

@pyxarez
Copy link
Author

pyxarez commented Aug 29, 2019

@HighSoftWare96 yay! Great news:)
I don't have enough time for it anyway:)
Thank you

@xtx1130
Copy link
Contributor

xtx1130 commented Aug 30, 2019

@pyxarez

But will this not lead to errors in the case when we really want to use execArgv?

I think it's better to move execArgv to fork's args.

@gbertoncelli
Copy link
Contributor

I think this issue can be closed, don't you @pyxarez ? The initial behaviour can be solved now by using:
fastify start --watch -l info -P app.js -d --debug-port=9230

@pyxarez
Copy link
Author

pyxarez commented Sep 2, 2019

Yeah, sure
Thank you all for your help!

@almgwary
Copy link

almgwary commented Jul 6, 2024

Anyone know how to start fustily start on debugging mode? all above solutions not working with me. debug server is started but not attached to the running server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

5 participants