Take the 2-minute tour ×

I am writing a chat AJAX app. Randomly, in FF 3.5.9, setInterval() seems to stop firing. I don't have clearInterval() anywhere in my code. What could be causing this to happen?

$(document).ready(function () {


    messageRefresher = new MessageRefresher(0);
    setInterval($.proxy(messageRefresher, "refresh"), 2000);

function notifyInRoom(user) {
    $.getJSON('API/users_in_room', { room_id: $.getUrlVar('key'), username: user }, function (users) {
        if (!$.isEmptyObject(users)) {
            $.each(users, function (index, username) {
                var newChild = sprintf("<li>%s</li>", username);
        else {
            $("#users-loading-msg").text("No one is in this room.");

function MessageRefresher(latest_mid) {
    this._latest_mid = latest_mid; 

MessageRefresher.prototype.refresh = function () {

    var refresher = this;
    $.getJSON('API/read_messages', { room_id: $.getUrlVar('key'), mid: refresher._latest_mid }, function (messages) {
        if (! (messages == null || $.isEmptyObject(messages[0]))) { // messages will always be at least [[], [], 0]
            for (var i = 0; i < messages[0].length; i++) {
                var newChild = sprintf('<li><span class="username">%s:</span> %s</li>', messages[1][i], messages[0][i]);
            refresher._latest_mid = messages[2];
        else {
            $("#messages-loading-msg").text("No messages here. Say anything...");


// Give the end-user-block class to the appropriate messages
// eg, those where the next message is by a different user  
function setUserBlockClass() {
    $("#messages li").each(function (index) {
        if ($(this).children(".username").text() != $(this).next().children(".username").text()) {

I checked the most recent responses in Firebug, and it was the same responses that had been sent earlier. (So, it's not like an unusual response caused a crash.)

If I refresh the page, the calls resume.

I'm setting breakpoints in Firebug while I develop, then unsetting them and hitting "continue". Is there any chance that this is causing the problem? UPDATE: With more testing, this seems like it might be the issue.

I'm also using the service in another browser, and the calls continue fine for it.

share|improve this question
Do you get any script errors? What happens if you add alert calls? –  SLaks Apr 9 '10 at 0:53
No script errors. Haven't tried alert calls yet. –  Rosarch Apr 9 '10 at 0:54
Even better would be console.log calls with Firebug. –  Sasha Chedygov Apr 9 '10 at 1:23

2 Answers 2

I'm seeing setInterval getting stopped when I debug with Firebug. Assume it's a timing/interrupt thing as it works fine as long as I'm not stepping over breakpoints.

share|improve this answer
I see this in Firefox 3.6. Breaking in Firebug kills the interval timer. In Firefox 5.0, breaking in Firebug kills mozRequestAnimationFrame, presumably for the same reason. See code.google.com/p/fbug/issues/… –  mhenry1384 Aug 10 '11 at 18:03

One thing to check that I just ran into was that if you are checking whether setInterval works with something like:


Firebug will only display the 'X' one time. Firebug appears to refuse to log the same text twice. However, testing in the Chrome console worked fine.

When I changed my test code to:

console.log(new Date());

Firebug gave me the results I expected.

share|improve this answer

Your Answer


