Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cron just stops - Possible Memory Leak #149

Closed
StevenDStanton opened this issue Feb 28, 2015 · 14 comments
Closed

Cron just stops - Possible Memory Leak #149

StevenDStanton opened this issue Feb 28, 2015 · 14 comments

Comments

@StevenDStanton
Copy link

I have a Cron job that just randomly stops. I started it at around 7:30PM and by 8:10 PM it just stopped.

I was logging output to my console and it just died.

 new CronJob('*/5 * * * * *', function(){
       console.log("***************************************************");
       console.log("Cron Start: " + Date());
       var https = require('https');
       var options = {
            host: 'api.twilio.com',
            port: 443,
            path: '/2010-04-01/Accounts/' + sid + '/Queues/'+ config.twilio.queue.sid  + '/Members.json',
            method: 'GET',
            auth: sid + ":" + auth,
            agent: false
       };
       var req = https.request(options, function(rex) {
         rex.setEncoding('utf8');
         rex.on('data', function (chunk) {
           try{
                  console.log("Cron Work : " + Date());
                 obj = JSON.parse(chunk);
                 io.sockets.emit('queue', {msg:obj.total.toString()});
                 io.sockets.emit('list', obj);
                 smsModel.find({agent: null}, function(err, results){
                          io.sockets.emit('chat', results);
                  console.log("Cron Data : " + Date());
              //console.log(results);
        });

      }catch(err){
        console.log("Code 1: " + err.message);
      } 
    });
  });
  req.end();
  console.log("Cron End  : " + Date());
  console.log("***************************************************");
}, null, true, "America/Los_Angeles");

It never logged any errors from my try catch blocks.

@StevenDStanton StevenDStanton changed the title Cron just stops Cron just stops - Possible Memory Leak Feb 28, 2015
@StevenDStanton
Copy link
Author

I tested further setting different cron times. I did it at 5, 10, and 20 second intervals and it seemed to have no effect on when it would fail.

I also monitored memory closely and while memory usage kept going up more and more while it was running until the crash it never maxed memory out.

Sometimes it would fail after 30 minutes, sometimes it would fail after 8 hours. It just seems to randomly and silently fail. Even when in a try catch block, in debugging mode, it just stops processing and goes blank with no errors reported.

all other portions of the server are working when this failure happens

@nathschmidt
Copy link

@StevenDStanton What version are you using? I've just had a similar issue with version 1.0.6, though there are some commits in the 1.0.8 release that fixes a similar issue #141

@StevenDStanton
Copy link
Author

I am using the latest version which is on NPM. According to my package.json file it is 1.0.8

@ncb000gt
Copy link
Member

ncb000gt commented Mar 3, 2015

@StevenDStanton I published a new version after this issue was reported. Are you still seeing the hanging behavior?

@StevenDStanton
Copy link
Author

I was experiencing it with version 1.0.8 3 days ago.

I had to stop using the software and move on to querying the server from the client side to get my updates to move forward with the project I am working on.

If you have released an update since 1.0.8 I can download it and test

@jBachalo
Copy link

Has this issue been resolved? Really important to know as a current project will be kiosk based and running 24-7.

@h0x91b
Copy link
Contributor

h0x91b commented Apr 12, 2015

I am fixed it, in our production servers works ok
On Sun, Apr 12, 2015 at 04:02 jBachalo notifications@github.com wrote:

Has this issue been resolved? Really important to know as a current
project will be kiosk based and running 24-7.


Reply to this email directly or view it on GitHub
https://github.com/ncb000gt/node-cron/issues/149#issuecomment-91956985.

@ncb000gt
Copy link
Member

@jBachalo the "stopping" bit was unrelated to a memory leak. That should be fixed in the latest version (although it sounds like @StevenDStanton is still having issues?).

I haven't seen or been able to reproduce a memory leak in the module locally, but that doesn't mean there isn't one. There is always a possibility that bugs exist. I'm not sure exactly what testing was done to prove a memory leak, but if the sample above is an example of what was tested then I'd recommend removing any excess code to rule out that as the memory leak culprit and seeing if the issue still exists.

@StevenDStanton
Copy link
Author

I stopped using it. We are moving forward quickly on the project I was using it on and we had to get a replacement. I plan to come back to it later on another project to see if it happens again

@ncb000gt
Copy link
Member

Ok. I'm going to close this for now. Can revisit if you do see a memory leak.

@mek-omkar
Copy link

mek-omkar commented May 15, 2016

i am facing similar problem, with cron 1.1.0 & nodev6.1.0. i configured every second job & not configured timezone

@semy
Copy link

semy commented May 25, 2016

Same problem.

cron 1.1.0 & nodev5.4.1
every second job with timezone

@semy
Copy link

semy commented May 25, 2016

@StevenDStanton What's your replacement of cron? Need a quick solution that works... Thanks :-)

@StevenDStanton
Copy link
Author

@semy I am actually just using two different methods.

Where it is not critical that my calls be exact to the second I am using javascripts setInterval.

It has proven to be surprising robust and accurate. Currently it runs my main loop which pushes out status updates to around 50 agents every 10 seconds.

For to the second precision I am using actual cron on my linux server. That is simple to set up with cron tab and cURL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants