{"action":"created","issue":{"url":"https://api.github.com/repos/lodash/lodash/issues/2893","repository_url":"https://api.github.com/repos/lodash/lodash","labels_url":"https://api.github.com/repos/lodash/lodash/issues/2893/labels{/name}","comments_url":"https://api.github.com/repos/lodash/lodash/issues/2893/comments","events_url":"https://api.github.com/repos/lodash/lodash/issues/2893/events","html_url":"https://github.com/lodash/lodash/issues/2893","id":196330801,"number":2893,"title":"_.debounce() breaks fake timers","user":{"login":"aldendaniels","id":4658558,"avatar_url":"https://avatars.githubusercontent.com/u/4658558?v=3","gravatar_id":"","url":"https://api.github.com/users/aldendaniels","html_url":"https://github.com/aldendaniels","followers_url":"https://api.github.com/users/aldendaniels/followers","following_url":"https://api.github.com/users/aldendaniels/following{/other_user}","gists_url":"https://api.github.com/users/aldendaniels/gists{/gist_id}","starred_url":"https://api.github.com/users/aldendaniels/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aldendaniels/subscriptions","organizations_url":"https://api.github.com/users/aldendaniels/orgs","repos_url":"https://api.github.com/users/aldendaniels/repos","events_url":"https://api.github.com/users/aldendaniels/events{/privacy}","received_events_url":"https://api.github.com/users/aldendaniels/received_events","type":"User","site_admin":false},"labels":[{"id":2763153,"url":"https://api.github.com/repos/lodash/lodash/labels/duplicate","name":"duplicate","color":"cccccc","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-12-19T04:48:53Z","updated_at":"2016-12-19T17:47:11Z","closed_at":"2016-12-19T15:10:18Z","body":"# _.debounce() breaks fake timers\r\n\r\nIn tests, it's common to replace JS timer methods such as `setTimeout` and `setInterval` with fake methods in order to control the passage of time. See [Jest Timer Mocks](https://facebook.github.io/jest/docs/timer-mocks.html) and [Sinon Fake Timers](http://sinonjs.org/docs/#clock). Doing this allows you to march the clock forward in tests, executing all timers synchronously. \r\n\r\nRecursive calls to `setTimeout` pose a problem when doing this, because the recursive `setTimeout` calls are executed synchronously, causing infinite recursion.\r\n\r\nA non-recursive debounce implementation would solve this. See [David Walsh's Debounce Function](https://davidwalsh.name/javascript-debounce-function) for an example of non-recursive debounce."},"comment":{"url":"https://api.github.com/repos/lodash/lodash/issues/comments/268029750","html_url":"https://github.com/lodash/lodash/issues/2893#issuecomment-268029750","issue_url":"https://api.github.com/repos/lodash/lodash/issues/2893","id":268029750,"user":{"login":"aldendaniels","id":4658558,"avatar_url":"https://avatars.githubusercontent.com/u/4658558?v=3","gravatar_id":"","url":"https://api.github.com/users/aldendaniels","html_url":"https://github.com/aldendaniels","followers_url":"https://api.github.com/users/aldendaniels/followers","following_url":"https://api.github.com/users/aldendaniels/following{/other_user}","gists_url":"https://api.github.com/users/aldendaniels/gists{/gist_id}","starred_url":"https://api.github.com/users/aldendaniels/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aldendaniels/subscriptions","organizations_url":"https://api.github.com/users/aldendaniels/orgs","repos_url":"https://api.github.com/users/aldendaniels/repos","events_url":"https://api.github.com/users/aldendaniels/events{/privacy}","received_events_url":"https://api.github.com/users/aldendaniels/received_events","type":"User","site_admin":false},"created_at":"2016-12-19T17:47:11Z","updated_at":"2016-12-19T17:47:11Z","body":"@jdalton not a dupe. #2533 addresses being unable to mock timers. Now we can  mock timers (:thumbsup:), but the timers recurse infinitely when mocked."}}
{"actor":{"display_login":"aldendaniels"}}