Skip to content

clearTimeout with invalid handle cause program runs longer #7722

@tdzl2003

Description

@tdzl2003
  • Version: Tested on 6.0.0
  • Platform: Tested on Windows & MacOS
  • Subsystem: Timer

This program cost 20 seconds, but 10.5 seconds was expected:

var handle = setTimeout(function(){ clearTimeout(handle); handle = setTimeout( function() { }, 10000 ); setTimeout( function() { clearTimeout( handle ); }, 500 ); }, 10000);

But all below codes work as expected:

var handle = setTimeout(function(){ clearTimeout(handle); handle = setTimeout( function() { }, 10000 ); setTimeout( function() { clearTimeout( handle ); }, 500 ); }, 2000); // <-- different delay 
var handle = setTimeout(function(){ //clearTimeout(handle); <-- comment this line. handle = setTimeout( function() { }, 10000 ); setTimeout( function() { clearTimeout( handle ); }, 500 ); }, 10000);

Does clearTimeout with a invalid handle causes this problem?

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.timersIssues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions