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

Nodemon restarts twice on file changes #48501

Closed
isidorn opened this issue Apr 24, 2018 · 12 comments
Closed

Nodemon restarts twice on file changes #48501

isidorn opened this issue Apr 24, 2018 · 12 comments
Assignees
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues *not-reproducible Issue cannot be reproduced by VS Code Team member as described

Comments

@isidorn
Copy link
Contributor

isidorn commented Apr 24, 2018

Refs: #48423

  1. Have a simple nodemon setup, using a nodemon sample
  2. Start debugging that sample and hit a breakpoint
  3. Make a change to that file and save
  4. Notice the session properly restars however it seems to restart twice
@isidorn isidorn added bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues labels Apr 24, 2018
@weinand weinand added this to the April 2018 milestone Apr 25, 2018
@weinand
Copy link
Contributor

weinand commented Apr 26, 2018

@roblourens This problem only occurs for "inspector" protocol.
And it was already broken in the Stable 1.22.2 release.

It seems to be a timing issue because it is almost impossible to reproduce when running in Dev Tools.

Here is the result of my tracing what's going on on the VS Code side (in rawDebugSession).
The initial number is an ID of the rawDebugSession (and the associated DA).

"legacy" works fine:

1: launch request (undefined)
<modify source>
1: terminated event (restart:{"restart":{"port":25168}})
1: disconnect request(restart:true)
1: exited event
2: launch request ({"port":25168})

"inspector" mostly works fine too when running it in Dev Tools:

1: launch request (undefined)
<modify source>
1: terminated event (restart:{"restart":{"port":28026}})
1: disconnect request(restart:true)
1: exited event
2: launch request ({"port":28026})

but sometimes "inspector" results in the debuggee launched twice:

1: launch request (undefined)
<modify source>
1: terminated event (restart:{"restart":{"port":15521}})
1: disconnect request(restart:true)
1: exited event
2: launch request ({"port":15521})
2: terminated event (restart:{"restart":{"port":15521}})   <--- the problem
2: disconnect request(restart:true)
2: exited event
3: launch request ({"port":15521})

The problem is the unexpected terminated event (see arrow) but I have no clue why this happens...
Maybe node-debug2 tries to attach too early, which fails and results in the terminated event.

I debugged node-debug2 a bit but I could not find the reason for the early Terminate event.

@weinand weinand modified the milestones: April 2018, May 2018 Apr 26, 2018
@weinand weinand removed their assignment Apr 26, 2018
@roblourens
Copy link
Member

I can't repro any problem with nodemon... was this fixed by any of the debug changes last week?

@weinand
Copy link
Contributor

weinand commented May 7, 2018

@isidorn since I did not change anything, did you?

@isidorn
Copy link
Contributor Author

isidorn commented May 8, 2018

I can still reproduce this with the following javascript file

console.log('hey2');

And with the following configuration

{
            "type": "node",
            "request": "launch",
            "name": "nodemon",
            "runtimeExecutable": "nodemon",
            "program": "${workspaceFolder}/hey.js",
            "restart": true,
            "console": "integratedTerminal",
            "internalConsoleOptions": "neverOpen"
        }

@roblourens
Copy link
Member

I guess I'm doing something wrong. Is this the right scenario? What does "restart twice" mean?

may-08-2018 18-18-00

@isidorn
Copy link
Contributor Author

isidorn commented May 9, 2018

@roblourens yes you are doing everything fine.
Restart twice means the debug toolbar blinks 2 times in practice. In your demo it blinks only once.

I have node version 8.9.1 and nodemon 1.11.0
Should I update something.
Can I debug this somehow on my machine so you get the needed info?

twice

@roblourens
Copy link
Member

Oh, you have auto attach enabled and are running it in the terminal, right? In your gif I see it switch into multi-session debug mode which is not right.

Could this just be related to #49403?

But you don't get the error popup.

@isidorn
Copy link
Contributor Author

isidorn commented May 10, 2018

@roblourens I can repro if I have auto-attach:false, however I can no longer repro if I remove
"console": "integratedTerminal" so it is somehow connected to that.
Not sure if the adapter is not respceting auto attach off when in intergrated terminal or something else is off.
But you could try to repro with adding intregratedTerminal.
Please note that our nodemon sample has integratedTerminal set so people might be running into this.

@weinand
Copy link
Contributor

weinand commented May 10, 2018

I'm pretty sure that this issue is not related to auto-attach.
But "auto-attach" must be off (and it was off when Isi filed the issue and I did my investigation).

Using the "integratedTerminal" is mandatory for the nodemon setup anyway because otherwise there is now way to interact with nodemon from the command line (e.g. for killing it).

@roblourens
Copy link
Member

roblourens commented May 10, 2018

I pointed out auto-attach because @isidorn's gif shows a second debug session starting (Process 9448 vs the original nodemon one)

I just can't repro any problem, so let's jump on a call to debug this, whenever one of you is free.

Or you could set "trace": true and give me the log but it might not have enough info to solve the problem because it will only show what happened during one session.

@isidorn
Copy link
Contributor Author

isidorn commented May 11, 2018

I investigated a bit more, and autoAttach seems to blame. So if I dsable autoAttach I can not repro.
I suggest to first fix #49403 and then look into this one

My previous comment that I can repro with autoAttach:off seems to be wrong -> or more likeyly the debug adapter was not picking up my change to disable autoAttach.

@weinand
Copy link
Contributor

weinand commented May 28, 2018

I'm no longer able to reproduce this.

@weinand weinand closed this as completed May 28, 2018
@weinand weinand removed this from the May 2018 milestone May 31, 2018
@weinand weinand added the *not-reproducible Issue cannot be reproduced by VS Code Team member as described label May 31, 2018
@isidorn isidorn removed the bug Issue identified by VS Code Team member as probable bug label Jun 28, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Jul 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues *not-reproducible Issue cannot be reproduced by VS Code Team member as described
Projects
None yet
Development

No branches or pull requests

3 participants