remy / nodemon

Monitor for any changes in your node.js application and automatically restart the server - perfect for development
http://nodemon.io/
MIT License
26.21k stars 1.72k forks source link

Exception thrown causing incomplete output to console #311

Closed danielkcz closed 10 years ago

danielkcz commented 10 years ago

Alright, I am not sure if this isn't purely Windows issue and I don't have option to test anywhere else. Given this really simple code:

console.log('Calling console.log');
console.error('Calling console.error');
console.log('Calling console.log second time - fails');
console.error('Calling console.error second time - fails');
nonexisting.throwError();

When I run it directly like node server.js it works just fine, all 4 messages are displayed followed by exception details. However running nodemon server.js gives me just this:

16 Mar 20:38:56 - [nodemon] starting `node server.js`
Calling console.log
Calling console.error

S:\workspace\server.js:5
nonexisting.throwError();
^
ReferenceError: nonexisting is not defined
......
16 Mar 20:38:56 - [nodemon] app crashed - waiting for file changes before starting...

What could be possibly causing this ? It doesn't make any sense... Of course commenting out that last error line displays all messages correctly.

It would not be that big deal, but thing is, that adding Coffeescript to the mix with nodemon server.coffee swallows whole exception too (maybe worth another issue submit). I am trying to utilize debug utility to have nice verbose log of what is happening in the app. Currently everything is just blind with no clue where the error occurred.

Oh and adding process.on('uncaughtException', ... somewhat fixes JS version, but Coffee version is still broken same way :( Not that it's solution I like, I want to handle exceptions on my own, but I am talking mainly about development times here and when something slips out.

remy commented 10 years ago

Can you share the output of the version with just node server.js for comparison?

danielkcz commented 10 years ago

Sure...

Calling console.log
Calling console.error
Calling console.log second time - fails
Calling console.error second time - fails

S:\workspace\server.js:5
nonexisting.throwError();
^
ReferenceError: nonexisting is not defined
.....

I had also made post to Stackoverflow just more focused around Coffeescript solution which is somewhat more serious. There is already one answer that could be right.

remy commented 10 years ago

Can you also paste the output of nodemon --dump server.js?

danielkcz commented 10 years ago
S:\workspace>nodemon --dump server.js
18 Mar 23:48:55 - [nodemon] v1.0.15
18 Mar 23:48:55 - [nodemon] to restart at any time, enter `rs`
18 Mar 23:48:55 - [nodemon] watching: *.*
--------------
{ run: false,
  system:
   { cwd: 'S:\\workspace',
     useFind: false,
     useWatch: true,
     useWatchFile: false },
  required: false,
  dirs: [ 'S:\\workspace' ],
  timeout: 1000,
  options:
   { scriptPosition: 0,
     dump: true,
     script: 'server.js',
     args: [],
     ignore:
      [ '.git',
        'node_modules/**/node_modules',
        re: /\.git|node_modules/.*.*/node_modules/ ],
     watch: [ '*.*', re: /.*\..*/ ],
     restartable: 'rs',
     execMap: { py: 'python', rb: 'ruby' },
     stdin: true,
     verbose: false,
     stdout: true,
     execOptions:
      { script: 'server.js',
        exec: 'node',
        nodeArgs: undefined,
        ext: 'js',
        env: {},
        execArgs: [] },
     ext: 'js',
     monitor: [ '*.*', '!.git', '!node_modules/**/node_modules' ] },
  load: [Function],
  reset: [Function: reset],
  lastStarted: 0,
  loaded: [],
  command:
   { raw: { executable: 'node', args: [ 'server.js' ] },
     string: 'node server.js' } }
--------------
OS: win32 x64
node: v0.10.26
nodemon: v1.0.15
cwd: S:\workspace
command: node D:\users\Fredy\AppData\Roaming\npm\node_modules\nodemon\bin\nodemon.js --dump server.js
--------------
remy commented 10 years ago

Got a fix being tested on windows today for this issue.

remy commented 10 years ago

Fixed in nodemon@1.0.17

danielkcz commented 10 years ago

Sounds promising, I will check it out, thanks !