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

grandma can only run for 24 days #157

Open
catdad opened this issue Jun 14, 2017 · 2 comments
Open

grandma can only run for 24 days #157

catdad opened this issue Jun 14, 2017 · 2 comments
Labels

Comments

@catdad
Copy link
Owner

catdad commented Jun 14, 2017

setTimeout has a thing... any larger value overflows and results in a negative, which causes setTimeout to complete immediately.

Thanks Greg.


Some libs, in order of how well they are actually implemented:

link notes
tellnes/long-timeout no arguments, but I rarely use those anyway
mikermcneil/set-dateout Mike likes reading StackOverflow... anyway, no way to cancel these, but never the less, a cool idea
trs/set-long-timeout Node 6+, so can't use for grandma, but a good model
@catdad catdad added the bug label Jun 14, 2017
@catdad catdad changed the title grandma can only run for 24 hours grandma can only run for 24 days Jun 14, 2017
@gabru-md
Copy link

gabru-md commented Jul 3, 2017

This is due to setTimeout using a 32 bit int to store the delay so the max value allowed would be
2147483647

There is another way that i may propose:
It is a very simple way/idea that may help you!

Let us consider that I want to run the code as mentioned below:

var myVar;

function myFunction(){
myVar = setTimeout(alertFunc,3000);
}

function alertFunc(){
alert("Just a try!");
}

// invoking myFunction()

myFunction()

The above code will simply generate an alert box after 3000 milliseconds.

Now let us suppose the case is that I want that the alert box must be created after ,lets say, some time which is an integral multiple of 3000.

One way would be rendering the above function:

function myFunction(){
myVar = setTimeout(alertFunc,3000*k);
}

where k is the constant term/ integer.

But another possible way would be:

var myVar;

function myFunction(){
myVar = setTimeout(alertFunc,3000);
}

function alertFunc(){
alert("Just a try!");
}

var temp;

function repeat_myFunction(){
t = setTimeout(myFunction,k*1000)
}

// invoking new function

repeat_myFunction()

Now you will notice that your initial function

myFunction()

will now be invoked after k*initial time.

For example put k*1000 = 2000 if you want the

myFunction()

to be repeated after TWICE the Initial time.

I hope this helps ! :D

@catdad
Copy link
Owner Author

catdad commented Oct 26, 2017

Blocked by #129.

@catdad catdad added this to backlog in uncategorized Jan 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
uncategorized
  
backlog
Development

No branches or pull requests

2 participants