• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!
Collapse

You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:

  • You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
  • You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
  • If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.

Previously on "NodeJS and script hangs"

Collapse

  • VectraMan
    replied
    Originally posted by NickFitz View Post
    Detecting that a program will run forever is known as the Halting Problem, and a certain Mr Alan Turing demonstrated quite a while ago that it's mathematically impossible to do so for the general case.

    So yes, don't write code that runs forever if you can help it
    Though it's relatively simple to have a different thread monitor the execution and if it doesn't get back to the event loop in a certain time, kill the script. This is what browsers do, so I'm a little surprised not to find it in Node.

    And because of the obsessively event driven single threaded nature of Node one connection can always affect everything else. It doesn't even need to be a bug: one thing that takes too long will stop it responding to all requests.

    I started my career doing software for Windows 3.1 so I'm well aware of the problems ;-) I didn't think I'd be doing it again, but that's progress for you.

    For a detailed examination of strategies for error and exception handling in Node, with particular reference to the case of using it in an HTTP server, have a look at Error Handling in Node.js.
    Thanks, that's very useful.

    Leave a comment:


  • NickFitz
    replied
    Detecting that a program will run forever is known as the Halting Problem, and a certain Mr Alan Turing demonstrated quite a while ago that it's mathematically impossible to do so for the general case.

    So yes, don't write code that runs forever if you can help it

    For a detailed examination of strategies for error and exception handling in Node, with particular reference to the case of using it in an HTTP server, have a look at Error Handling in Node.js.

    Leave a comment:


  • VectraMan
    started a topic NodeJS and script hangs

    NodeJS and script hangs

    I've been experimenting with Node JS and I was wondering what would happen if the script gets stuck in a loop. I.e. while(true);

    I'll tell you what happens: it keeps running that loop; running one core at 100% until the end of time and stops responding to any events, even if they come from other clients/IPs (assuming Node is running a webserver that is). Basically a dead server because of one script bug, which strikes me as quite poor.

    The other less than ideal thing I've discovered is that (by default at least) runtime errors result in it calling exit(), which again takes down the whole server rather than just the one connection.

    What do people who use NodeJS for serious stuff do? Or is it a case of don't write code with bugs in it?
    Last edited by VectraMan; 29 May 2015, 10:45.

Working...
X