I've seen this post: Server hangs on Running "concurrent:server" (concurrent) task but the solutions there don't appear to be the source of what I'm seeing. I'm wondering if it's a bug with IntelliJ but thought I'd ask before I submit to Jetbrains.
I'm using a brand-new, freshly-built Yeoman angular-fullstack and trying to debug into app.js or seed.js for example - something that runs immediately after the server starts up. As such, I either need to start a server with node --debug-brk so the server waits until I manually connect the debugger or start the server in a way that IDEA connects its debugger immediately.
This runs just fine from the command line running grunt serve. However, doing the same in IDEA as a debug config hangs on the concurrent:server task.
This is all 100% out of the box angular-fullstack, but I'll put the code here for reference anyway.
Here's the portion of the "serve" task that runs when no target is specified, as in the case I'm talking about here:
grunt.task.run([
'clean:server',
'env:all',
'injector:sass',
'concurrent:server',
'injector',
'wiredep',
'autoprefixer',
'express:dev',
'wait',
'open',
'watch'
]);
Here's the concurrent portion of the Gruntfile where things are getting hung up:
concurrent: {
server: [
'sass',
],
test: [
'sass',
],
debug: {
tasks: [
'nodemon',
'node-inspector'
],
options: {
logConcurrentOutput: true
}
},
dist: [
'sass',
'imagemin',
'svgmin'
]
}
More detail below but the only way I have this working right now is to change the concurrent:server line in the task to sass to just use what's in the server section of the concurrent task anyway. That
So right now I have the following options that I've tried, along with the associated problems I'm encountering:
Approach #1: Start the server via an IDEA NodeJS debug config running grunt serve
Here's the console output for this approach:
/usr/local/bin/node --debug-brk=65524 --nolazy --debug /usr/local/bin/grunt serve
debugger listening on port 65524
Running "serve" task
Running "clean:server" (clean) task
Running "env:all" (env) task
Running "injector:sass" (injector) task
Missing option `template`, using `dest` as template instead
Injecting scss files (3 files)
>> Nothing changed
Running "concurrent:server" (concurrent) task
Approach #2: Using the same debug config from #1, do a "run" instead of a "debug"
--debug-brk in the command line, nor --nolazy, first line is this instead: /usr/local/bin/node /usr/local/bin/grunt servePer above the only way I got this working fully was to change out the concurrent:server portion of the task explicitly. My concern is if I do want the concurrent capability, I really have no way to debug the early-loaded portions of the app without unrolling the entire concurrent task.
My other option is to create a new task specific to IntelliJ that unrolls it, but that's still a hack...
Is this an IntellliJ bug or is something else going on?
The problem is caused by the way Grunt spawns child tasks. By default, the spawned child process uses the same debug port as a parent process - as a result the forked process is suspended and the application 'stalls'. See How to fork a child process that listens on a different debug port than the parent, for example.
Please try adding
process.execArgv = [];
at the top of your Gruntfile.js
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With