Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9107601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:36:42+00:00 2026-06-17T02:36:42+00:00

I am new to javascript and node, and have been trying to create an

  • 0

I am new to javascript and node, and have been trying to create an application using node.js and express.

I have put appropriate callbacks for errors but they are not put everywhere, and sometimes node.js server just stops because of some exception that comes in.

It has been recommended to use ‘upstart’ or ‘forever’ to keep the node.js running always and start it whether node.js stops.

It seems express provides a catch all for all the exceptions by the following from the link http://expressjs.com/guide.html#error-handling

app.use(function(err, req, res, next){
  console.error(err.stack);
  res.send(500, 'Something broke!');
});

It is working for me now. However i read somewhere that catching error like this is not a good idea as it can have side effects and can leave the variables in an inconsistent state?
Also catching exception like this does not work for all the cases, and there can be some cases when the server can still stop for some exception. Is it true?

My questions are probably this.

1) Can the exception handling like above can leave some variables in an inconsistent state?
2) Can there be some exceptions which will still stop the server?

Thanks & Regards

Tuco

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T02:36:43+00:00Added an answer on June 17, 2026 at 2:36 am

    1) Whether this exception handling method can leave some variables in an inconsistant state depends on your implementation.

    If you scope all the variables to the specific request and functions and dont access global or higher variables like the global app object, you will be fine. Unused memory gets cleaned up right after the exception by garbage collector.

    2) Yes, it is possible for some exception to stop the server. Therefore you should set a global exception handling handler for the process like this: http://nodejs.org/api/process.html#process_event_uncaughtexception

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

New to javascript and such, trying to create a loop for fading logos using
I have a node application I am trying to host on Azure, that create
I don't have much experience with Javascript, Node.js or Socket.io. I'm trying to create
I'm new to node and javascript and have been banging my head on the
I'm relatively new javascript, but I am comfortable in other languages. I'm trying to
I'm trying to make a new spine javascript app using d3 (generated using Spine.app).
Just started to play around with node.js, have some past experience with JavaScript but
I am attempting to make something simple using Node.js and Express. I have a
Have been following this fabulous tutorial . Being new to Javascript and functional programming,
I have read that a HTTP server created in node.js does not create new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.