Alex Rivera | Logout

Nowjs: [RangeError: Maximum call stack size exceeded]

Asked 2012-05-31T05:48:36.820
10

When I start the server on port 8080 it doesn't give me an error, but when I am trying to browse the http://localhost:8080/nowjs/now.js the server raises an error:

[RangeError: Maximum call stack size exceeded]
undefined

I tried the same with socket.io and it worked fine.

Edit
Report

1 Answer

4

I've had two problems with now.js that produce this error message. Hopefully one of them will help you.

Circular References

You cannot include any circular references in objects passed into now, or it's extend method will barf. There were some optimizations and workarounds for this and it's now listed as an closed issue, but I have run into it.

initialize() only once

Second, you may not call require('now').initialize(...) twice or the two instances have a little intellectual conversation and race each other right out of the stack.

What I did instead was to create everyone in app.js and pass it into all my require(...) methods that need to reference the now "pocket".

In /app.js:

var conf = {
    everyone: require('now').initialize(app)
    port: 3000,
    // etc...
};

require('./routes')(conf)
// etc...

In routes/index.js:

module.exports = function(conf) {
   var everyone = conf.everyone;

   return {
       send: function() {
           everyone.now.clientFxn(...);
       }
   }
}
answered 2012-06-10T04:19:51.790

Your Answer