Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
holiman opened this issue May 23, 2015 · 6 comments
Closed
Assignees

Comments

@holiman
Copy link
Contributor

holiman commented May 23, 2015

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.

@zelig
Copy link
Contributor

zelig commented May 24, 2015

excellent catch, thanks, @zsfelfoldi take it?

@zelig
Copy link
Contributor

zelig commented Jun 1, 2015

fixed in #1090

@holiman
Copy link
Contributor Author

holiman commented Jun 9, 2015

This does not seem to be fixed at all. This is with the latest (as of today) code on develop branch (v0.9.27-5f341e5d):

#./geth --networkid=-123 --datadir=/home/martin/tmp/.ethereum2 console
I0609 20:58:52.030889    5890 backend.go:256] Protocol Version: 60, Network Id: -123
I0609 20:58:52.031011    5890 backend.go:266] Blockchain DB Version: 3
I0609 20:58:52.036284    5890 chain_manager.go:250] Last block (#0) fd4af92a79c7fc2fd8bf0d342f2e832e1d4f485c85b9152d2039e03bc604fdca TD=131072
I0609 20:58:52.040033    5890 cmd.go:148] Starting Geth/v0.9.27-5f341e5d/linux/go1.4.2
I0609 20:58:52.040116    5890 server.go:293] Starting Server
I0609 20:58:54.145190    5890 udp.go:189] Listening, enode://c9eb03c15eff8a3875df06d6d1670cb3f0757a4d3f547e88041d20c01e9a62db9a941a3d64148fd300a94aa916b3cc3b2b39584db420c587c771830d5b16c59b@[::]:30303
I0609 20:58:54.145409    5890 backend.go:477] Server started
I0609 20:58:54.145390    5890 server.go:530] Listening on [::]:30303
> 
> var timer = setInterval(function(){console.log("bananas"+timer);clearInterval(timer);}, 2000);
undefined
> bananas[object Object]
bananas[object Object]
bananas[object Object]

> ^C

It does not seem like I can reopen this bug, can someone please confirm and/or reopen this ?

@fjl
Copy link
Contributor

fjl commented Jun 9, 2015

It has not been fixed indeed. @zelig was a bit too quick with closing this issue.

@fjl fjl reopened this Jun 9, 2015
@zelig
Copy link
Contributor

zelig commented Aug 24, 2015

@fjl status on this?

@fjl
Copy link
Contributor

fjl commented Sep 17, 2015

fixed in #1811.

@fjl fjl closed this as completed Sep 17, 2015
@fjl fjl removed the in progress label Sep 17, 2015
maoueh pushed a commit to streamingfast/go-ethereum that referenced this issue Nov 29, 2023
* added cache.blocklogs (FilterLogCacheSize) flag

* updated docs

* minor fix

Co-authored-by: Mael Regnery <mael@mqli.fr>

---------

Co-authored-by: Mael Regnery <mael@mqli.fr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants