question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

window.setTimeout called immediately

See original GitHub issue

🐞 bug report

Affected Package

?

Is this a regression?

Not sure.

Description

Setting high value for the delay on window.setTimeout causes the callback to be executed before it should (almost immediately). Did not figure out the threshold number yet…

🔬 Minimal Reproduction

https://stackblitz.com/edit/angular-timeout-bug

🔥 Exception or Error


window.setTimeout(() => {
  console.log("long delay called");
}, 2667780325);

window.setTimeout(() => {
  console.log("25sec delay called");
}, 25000);

Should print to console 25sec delay called first, and (much) later long delay called. It prints long delay called instead first, then 25 seconds later 25sec delay called

🌍 Your Environment

Angular Version:


Angular CLI: 7.1.4
Node: 10.1.0
OS: linux x64
Angular: 7.1.4
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.11.4
@angular-devkit/build-angular     0.11.4
@angular-devkit/build-optimizer   0.11.4
@angular-devkit/build-webpack     0.11.4
@angular-devkit/core              7.1.4
@angular-devkit/schematics        7.1.4
@angular/cdk                      7.2.0
@angular/material                 7.2.0
@ngtools/webpack                  7.1.4
@schematics/angular               7.1.4
@schematics/update                0.11.4
rxjs                              6.3.3
typescript                        3.1.6
webpack                           4.23.1

But the stackblitz example uses


"@angular/common": "^7.2.5",
    "@angular/compiler": "^7.2.5",
    "@angular/core": "^7.2.5",
    "@angular/forms": "^7.2.5",
    "@angular/platform-browser": "^7.2.5",
    "@angular/platform-browser-dynamic": "^7.2.5",
    "@angular/router": "^7.2.5",
    "core-js": "^2.6.5",
    "rxjs": "^6.4.0",
    "zone.js": "^0.8.29"

Anything else relevant? Tried in chrome, no other browser.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
bitbaycommented, May 10, 2019

@ericmartinezr …that was FAST! Thank You both very much!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is the method executed immediately when I use ...
The reason is that the first argument to setTimeout should be a function reference, not the return value of the function. In your...
Read more >
setTimeout() - Web APIs - MDN Web Docs
The global setTimeout() method sets a timer which executes a function or specified piece of code once the timer expires.
Read more >
Problem: javascript setTimeout executes function immediately
JavaScript has setTimeout() method which calls a function or evaluates an expression after a specified number of milliseconds. See below code,
Read more >
Window setTimeout() Method - W3Schools
The setTimeout() method calls a function after a number of milliseconds. 1 second = 1000 milliseconds. Notes. The setTimeout() is executed only once....
Read more >
How to use setTimeout() in JavaScript? - Tabnine
The setTimeout function is a native JavaScript function. It sets a timer (a countdown set in milliseconds) for an execution of a callback...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found