Typing "rs" to restart causes stream error and nodemon crash #289

Closed
feross opened this Issue Jan 31, 2014 · 23 comments

Comments

6 participants

feross commented Jan 31, 2014

To reproduce:

nodemon -x yes

Then type "rs" and hit ENTER.

You get:

exception in nodemon killing node
Error: write after end
    at writeAfterEnd (_stream_writable.js:144:12)
    at Socket.Writable.write (_stream_writable.js:191:5)
    at Socket.write (net.js:603:40)
    at ReadStream.ondata (_stream_readable.js:534:20)
    at ReadStream.EventEmitter.emit (events.js:126:20)
    at readableAddChunk (_stream_readable.js:156:16)
    at ReadStream.Readable.push (_stream_readable.js:123:10)
    at TTY.onread (net.js:511:20)

If appropriate, please file an error: http://github.com/remy/nodemon/issues/new
Owner

remy commented Feb 4, 2014

Is the on mac or linux? I've got a mac and running yes just repeats "y" down the screen, and doesn't even allow time to read from stdin for the rs command (so I guess you're on linux?)

remy added the needs more info label Feb 4, 2014

feross commented Feb 5, 2014

I've also got a mac. The crash has nothing to do with the yes command. Anytime I type "r s ENTER", I get the crash. For example:

$ cat test.js
setInterval(function () {}, 1000)
$ nodemon test.js
4 Feb 22:32:55 - [nodemon] v1.0.14
4 Feb 22:32:55 - [nodemon] to restart at any time, enter `rs`
4 Feb 22:32:55 - [nodemon] watching: *.*
4 Feb 22:32:55 - [nodemon] starting `node test.js`
rs
exception in nodemon killing node
Error: write after end
    at writeAfterEnd (_stream_writable.js:144:12)
    at Socket.Writable.write (_stream_writable.js:191:5)
    at Socket.write (net.js:603:40)
    at ReadStream.ondata (_stream_readable.js:534:20)
    at ReadStream.EventEmitter.emit (events.js:126:20)
    at readableAddChunk (_stream_readable.js:156:16)
    at ReadStream.Readable.push (_stream_readable.js:123:10)
    at TTY.onread (net.js:511:20)

If appropriate, please file an error: http://github.com/remy/nodemon/issues/new

Running the latest version:

$ nodemon -v
v1.0.14

feross commented Feb 5, 2014

On OS X Mountain Lion 10.9.1. Do you not get the same behavior?

Owner

remy commented Feb 18, 2014

Sorry, been too busy to catch recent nodemon issues.

I'm using 10.9.1 also, and not getting this behaviour. What's the output of yes for you without nodemon?

feross commented Feb 19, 2014

Tons of ys with newlines between them.

zauguin commented Mar 3, 2014

I've got the same problem with archlinux and nodemon 1.0.15 from npm

same problem on ubuntu 13.10 with nodemon 1.0.15 from npm

Owner

remy commented Mar 11, 2014

Running what commands?

On Tuesday, March 11, 2014, Trevor Baron notifications@github.com wrote:

same problem on ubuntu 13.10 with nodemon 1.0.15 from npm

Reply to this email directly or view it on GitHubhttps://github.com/remy/nodemon/issues/289#issuecomment-37260992
.

-- Remy

Owner

remy commented Mar 11, 2014

@feross can you give me the output of nodemon test.js --dump (with your setInterval example)?

feross commented Mar 16, 2014

@remy Okay, pretty sure I figured out the issue. The error only happens with Node 0.11. I should have suspected this sooner -- sorry for the goose chase.

Node 0.11.12 gives:

exception in nodemon killing node
Error: write after end
    at writeAfterEnd (_stream_writable.js:144:12)
    at Socket.Writable.write (_stream_writable.js:191:5)
    at Socket.write (net.js:612:40)
    at ReadStream.ondata (_stream_readable.js:533:20)
    at ReadStream.EventEmitter.emit (events.js:126:20)
    at readableAddChunk (_stream_readable.js:156:16)
    at ReadStream.Readable.push (_stream_readable.js:123:10)
    at TTY.onread (net.js:520:20)

but Node 0.10 works just fine.

feross commented Mar 16, 2014

Here's the output you requested, if that's helpful:

15 Mar 17:59:27 - [nodemon] v1.0.15
15 Mar 17:59:27 - [nodemon] to restart at any time, enter `rs`
15 Mar 17:59:27 - [nodemon] watching: *.*
--------------
{ run: false,
  system: 
   { cwd: '/Users/feross/code',
     useFind: true,
     useWatch: false,
     useWatchFile: false },
  required: false,
  dirs: [ '/Users/feross/code' ],
  timeout: 1000,
  options: 
   { scriptPosition: 0,
     dump: true,
     script: 'test.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: 'test.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: [ 'test.js' ] },
     string: 'node test.js' } }
--------------
OS: darwin x64
node: v0.11.12
nodemon: v1.0.15
cwd: /Users/feross/code
command: node /usr/local/bin/nodemon test.js --dump
--------------

I also have this problem

rs
[nodemon] manual restart requested
events.js:82
      throw er; // Unhandled 'error' event
            ^
Error: write after end
    at writeAfterEnd (_stream_writable.js:144:12)
    at Socket.Writable.write (_stream_writable.js:191:5)
    at Socket.write (net.js:612:40)
    at ReadStream.ondata (_stream_readable.js:533:20)
    at ReadStream.EventEmitter.emit (events.js:126:20)
    at readableAddChunk (_stream_readable.js:156:16)
    at ReadStream.Readable.push (_stream_readable.js:123:10)
    at TTY.onread (net.js:520:20)
Owner

remy commented Mar 18, 2014

@yanickrochon you'll need to provide the details of the --dump output otherwise I'm having to guess what you're actually doing.

Owner

remy commented Mar 18, 2014

@feross I'll get node 0.11.x installed and investigate - cheers.

Owner

remy commented Mar 18, 2014

Finally able to replicate with 0.11.x - not sure what's causing it though.

feross commented Mar 18, 2014

@remy The streams implementation changed subtly in node 0.11. One simple solution would be to replace all require('stream') with require('readable-stream') and you'll get a consistent streams implementation across different node versions.

See: http://www.nearform.com/nodecrunch/dont-use-nodes-core-stream-module cc @rvagg

rvagg commented Mar 18, 2014

summary: readable-stream@1.0.x for v0.10 streams (streams2), readable-stream@1.1.x for v0.11 streams (streams3)

Owner

remy commented Mar 19, 2014

nodemon isn't actually using require('stream') anywhere...

@remy I tried the --dump switch, but there's nothing more to say... the error is still the same.

Owner

remy commented Mar 19, 2014

@yanickrochon the --dump gives me your config so I can see what's going on inside.

@remy I see. I am not running nodemon directly, but as a module, so this is why I was confused. I installed nodemon globally and ran the --dump flag, but I'm not sure why you need that dump.... it's not representative of how the application is launched. Are you sure you still want that dump?

Owner

remy commented Mar 20, 2014

@yanickrochon okay, actually I think what I need is your version of node. If it's 0.11.x then it's related to the issue the others have reported. If not, then there's something else happening, and I need more information to be able to replicate.

@remy yes, I'm using node v0.11.12. And I think that the problem is, in fact, related to what @feross is suggesting.

@remy remy added bug and removed needs more info labels Apr 4, 2014

remy closed this in 59a5851 Apr 4, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment