title: Getting Maximum call stack size exceeded error in nodejs
body: <p>I am new to Node.js and i am developing a simple chat app using <strong>Socket.IO</strong>.
  I made an <strong>index.js</strong> file and an <strong>index.html</strong> file. </p>
  
  <p>My <strong>index.js</strong> files looks like this </p>
  
  <pre><code>var app = require('express')();
  var http = require('http').Server(app);
  var io = require('socket.io')(http);
  process.stdin.resume();
  process.stdin.setEncoding('utf8');
  var util = require('util');
  
  app.get('/', function(req, res){
    res.sendFile(__dirname + '/index.html');
  });
  
  io.on('connection', function(socket){
    socket.on('chat message', function(msg){
       console.log('message: ' + msg);
     });
     var txt = process.stdin.on('data', function (text) {
       process.tick()
       return util.inspect(text)
     });
    socket.emit('chat message',txt);
  });
  
  http.listen(3000, function(){
    console.log('listening on *:3000');
  });
  </code></pre>
  
  <p>My index.html file looks like this</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;Socket.IO chat&lt;/title&gt;
      &lt;style&gt;
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body { font: 13px Helvetica, Arial; }
        form { background: #000; padding: 3px; position: fixed; bottom: 0; width: 100%; }
        form input { border: 0; padding: 10px; width: 90%; margin-right: .5%; }
        form button { width: 9%; background: rgb(130, 224, 255); border: none; padding: 10px; }
        #messages { list-style-type: none; margin: 0; padding: 0; }
        #messages li { padding: 5px 10px; }
        #messages li:nth-child(odd) { background: #eee; }
      &lt;/style&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;ul id="messages"&gt;&lt;/ul&gt;
      &lt;form action=""&gt;
        &lt;input id="m" autocomplete="off" /&gt;&lt;button&gt;Send&lt;/button&gt;
      &lt;/form&gt;
      &lt;script src="https://cdn.socket.io/socket.io-1.2.0.js"&gt;&lt;/script&gt;
      &lt;script src="http://code.jquery.com/jquery-1.11.1.js"&gt;&lt;/script&gt;
      &lt;script&gt;
        var socket = io();
        $('form').submit(function(){
          socket.emit('chat message', $('#m').val());
          $('#m').val('');
          return false;
        });
        socket.on('chat message', function(msg){
          $('#messages').append($('&lt;li&gt;').text(msg));
        });
      &lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I am trying to take value from the console and print it on the browser and vice versa. In this app the chat is between the client and the server. </p>
  
  <p>When i run the <strong>index.js</strong> file i get this on the terminal</p>
  
  <pre><code>listening on *:3000
  </code></pre>
  
  <p>All is fine until i hit the server with <strong>localhost:3000</strong> from my browser and then i get this on the terminal </p>
  
  <pre><code>buffer.js:0
  (function (exports, require, module, __filename, __dirname) { // Copyright Joy
  ^
  RangeError: Maximum call stack size exceeded
  </code></pre>
  
  <p>How can i solve this? I want to get the value from the console(server) and send it to the browser(client). </p>
  
  <p><strong>Update 1</strong> </p>
  
  <p>I get this error </p>
  
  <pre><code>process.tick()
               ^
  TypeError: Object #&lt;process&gt; has no method 'tick'
      at ReadStream.&lt;anonymous&gt; (/home/sunil/Downloads/TPL/chat/index.js:16:14)
      at ReadStream.EventEmitter.emit (events.js:95:17)
      at ReadStream.&lt;anonymous&gt; (_stream_readable.js:746:14)
      at ReadStream.EventEmitter.emit (events.js:92:17)
      at emitReadable_ (_stream_readable.js:408:10)
      at emitReadable (_stream_readable.js:404:5)
      at readableAddChunk (_stream_readable.js:165:9)
      at ReadStream.Readable.push (_stream_readable.js:127:10)
      at TTY.onread (net.js:526:21)
  </code></pre>
  
  <p><strong>Update 2</strong> 
  <strong>process.tick()</strong> was replaced by <strong>process.nextTick()</strong>
  and then i get this error </p>
  
  <pre><code>node.js:415
              callback();
              ^
  TypeError: undefined is not a function
      at process._tickCallback (node.js:415:13)
  </code></pre>