Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8841349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:41:36+00:00 2026-06-14T10:41:36+00:00

I have a recursive polling function that does some stuff and then calls itself

  • 0

I have a recursive polling function that does some stuff and then calls itself with a setTimeout of 100 ms. However, if I call another synchronous function that does some stuff for a long time while the recursive polling function is running, I assume the function called with a setTimeout of 100ms will be queued, but if that long function does not return within a specified amount of time, will the browser simply discard the queued function? I’m asking this because it seems that the recursive polling function stops running after this other long running function is called. Also I checked with console.log‘s that the recursive function reaches and calls the setTimeout but the function passed to setTimeout never is called after the long synchronous function is called. This is all in Chrome 23 and Firefox 15.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T10:41:38+00:00Added an answer on June 14, 2026 at 10:41 am

    setTimeout functions cannot be “automatically” cancelled – so long as you allow the browser to return to its event loop they will get called.

    Should you want to have a timer function that cancels itself automatically that should be relatively easy to achieve:

    window.setTimeoutMaybe = function(f, t0, t1) {
        t1 = t1 || (t0 * 10);
        var then = new Date();
        return window.setTimeout(function() {
            var now = new Date();
            if (now - then < t1) {
                f();
            } 
        }, t0);
    };
    

    i.e. call f after time t0, but only if time t1 hasn’t passed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a recursive function (in C#) that I need to call about 800
I have a recursive function which contains some drawing code inside. I was advised
Suppose we have a recursive function, f , that might fail if the input
I'm writing an android app where you have a recursive function that takes a
I have a recursive scalar function that needs to update a record in another
I have a recursive call to a method that throws a stack overflow exception.
I have a recursive function for moving some circles on a canvas. Overed circle
I have a recursive call to perform some logged movements from user. While the
I have a recursive function that spawns several async tasks. Each task updates a
I have a recursive function that will repeat the function until the if condition

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.