Maximum Angularjs $ timeout value

I am using angularjs and in particular $ timeout service (wrapper on setTimeout). It works as follows:

 angular.module('MyApp').controller('MyController', ['$scope', '$timeout',
     function($scope, $timeout) {

        $scope.millisecondsLater = 3000000000;
        $timeout(function(){
           console.log('it\ been ' + $scope.millisecondsLater + ' later');
        }, $scope.millisecondsLater);

    }
 ]);

when this controller is created, the timeout function is called immediately. But if I installed:

  $scope.millisecondsLater = 2000000000; 

it does not seem to be called as expected because it is (after 2,000,000 seconds). And roughly, if I set $ scope.millisecondsLater = 2000, the callback will be called 2 seconds later.

It looks like $ timeout has a maximum value somewhere between 3,000,000,000 and 2,000,000,000, and instead of never calling a callback, it is immediately called (for chromium at least). Has anyone come across this before? and how did you completely resolve it without a bunch of hard coding if <2000000000 checks when timeouts are used?

, !

+4
1

, $timeout Angular, setTimeout, JavaScript ( $timeout setTimeout).

setTimeout 32- ( 2147483647). , , , . , ?

+5

Source: https://habr.com/ru/post/1528011/


All Articles