Skip to content

Geth console: clearInterval/clearTimeout fails from within setInterval function #1083

Closed
@holiman

Description

@holiman

It does not seem possible to clear a timer from within the timer. This is not due to variable scoping (at least not on the JS-side), since the returnvalue timer is available - see below.

Actual result (geth console) - the timer is not cleared until I manually call clearInterval:

> var timer = setInterval(function(){console.log("bananas"+timer);clearInterval(timer);}, 2000);
undefined
> bananas[object Object]
bananas[object Object]
bananas[object Object]
> clearInterval(timer);

Expected result (from Google Chrome) - the timer clears itself successfully:

>var timer = setInterval(function(){console.log("bananas"+timer);clearInterval(timer);}, 2000);

undefined
VM148:2 bananas107
>var timer = setInterval(function(){console.log("bananas"+timer);clearInterval(timer);}, 2000);

undefined
VM149:2 bananas108

Oh, and it can be noted that the geth console does not return an id, like other JS engines, but instead some kind of special Object (some form of "otto value" from a go type, whatever that is). Perhaps this should be changed into an integer instead, for library compatibility with other platforms.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions