Node.js restarts consistently after 400 requests

Hi - I am using Passenger to manage my Node.js app on a VPS. I have a simple test app using Express which simply increments an app.locals.count variable. The client loops a request to the node app and displays the current count. When the count gets to 400, the app restarts. I am sending the count and an app start time to the client to confirm that the node app has restarted. Is this a matter of Passenger, Exress or Node? Is there some way to tell the app not to restart?

The node app is:

const express = require('express')
const app = express()

global.starttime = new Date().toTimeString();
app.locals.count = 0;

app.get('/counter', (req, res) => {
	res.json({count: count++, start: global.starttime});
})

app.listen(3000, () => console.log(`Example app listening on port ${port}!`))

The client code is:

<html>
	<head>
	</head>
	<body>
		
		<p id="demo"></p>
		
		
		<script>
			var xmlhttp = new XMLHttpRequest();
			
			xmlhttp.onreadystatechange = function() 
			{
			  if (this.readyState == 4 && this.status == 200) 
			  {
			    var myObj = JSON.parse(this.responseText);
			    document.getElementById("demo").innerHTML = myObj.count + " :: " + myObj.start;
			    
			    setTimeout(() => {
				     xmlhttp.open("GET", "https://theURL/counter?id="+Math.floor(Math.random() * 100000) + 1, true);
					 xmlhttp.send();
			    }, 1000);
			   
			  }
			};

			xmlhttp.open("GET", "theURL/counter?id="+Math.floor(Math.random() * 100000) + 1, true);
			xmlhttp.send();
				
			</script>	
	</body>
</html>

The output on the client page is:
192 :: 16:47:22 GMT-0700 (Pacific Daylight Time)

When it gets to a count of 400, the count goes back to zero and the star time is new. Does Passenger kick the node server every 400 requests? Can this be set to something else?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.