Event loop debugging in dart:io

254 views
Skip to first unread message

Greg Lowe

unread,
Dec 3, 2014, 5:06:27 PM12/3/14
to mi...@dartlang.org
So a dart:io program exits once all timers and future.timeouts have completed and sockets have been closed.

Often in my tests I have a problem where the program won't complete because something hasn't been closed, or a timer is still running.

What is the best way to debug this?

So far the only way I have found, is to run in the debugger, and pause after main has finished, and then step through a lot of lines of internal dart code until I find some application code.

Ideally there would be a way to see all incomplete timers, unclosed sockets, etc, that are keeping the program alive.

Cheers,
Greg.

Alan Knight

unread,
Dec 3, 2014, 5:10:21 PM12/3/14
to mi...@dartlang.org
Yes, ideally there would. https://code.google.com/p/dart/issues/detail?id=20857

--
For other discussions, see https://groups.google.com/a/dartlang.org/
 
For HOWTO questions, visit http://stackoverflow.com/tags/dart
 
To file a bug report or feature request, go to http://www.dartbug.com/new

To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.

Greg Lowe

unread,
Dec 3, 2014, 5:17:06 PM12/3/14
to mi...@dartlang.org
Starred. 

Any workarounds in the meantime?

Perhaps using the debugger to set a watch on a private member of some internal implementation class in the SDK. I'm not sure where to start looking.

Natalie Weizenbaum

unread,
Dec 3, 2014, 6:54:36 PM12/3/14
to General Dart Discussion
You might be able to whip something up with the Zone API.

Greg Lowe

unread,
Dec 3, 2014, 7:21:43 PM12/3/14
to mi...@dartlang.org
Yes I was thinking about that. That would allow intercepting calls to timers. But not for tracking open sockets, or even just calls to socket connect that haven't resulted in a socket yet. Socket connect is a tricky one since it uses the OS's timeout (~120sec). I guess I need to mock Socket.connect(), and add the socket to a list, and remove it when it's closed.

I just noticed that I can inspect instances in the allocation profile tab of observatory. That's probably the best place to start.

Lasse R.H. Nielsen

unread,
Dec 4, 2014, 1:46:36 AM12/4/14
to mi...@dartlang.org

Would it be possible to have the observatory show what it's keeping an isolate alive? Or the debugger?
/L

Anders Holmgren

unread,
Dec 8, 2014, 2:10:48 AM12/8/14
to mi...@dartlang.org
+1 happens all the time in tests for me

Lex Berezhny

unread,
Dec 8, 2014, 2:35:13 AM12/8/14
to misc

I have a related issue still open: https://code.google.com/p/dart/issues/detail?id=21674

Søren Gjesse

unread,
Dec 8, 2014, 2:56:35 AM12/8/14
to General Dart Discussion
There is currently an experimental (and hidden) IO addition to the observatory. If you navigate to an isolate by clicking on the isolate on the observatory main page (main isolate will be named root). That will take you to the url http://localhost:8181/#/isolates/<isolate id>. If you append /io (http://localhost:8181/#/isolates/<isolate id>/io) to that you will see some dart:io information.

This is not finished, but it might be helpful in some situations. Currently it only have sockets and files.

Regards,
Søren Gjesse

---
Søren Gjesse
Software Engineer, Google Denmark
CVR nr. 28 86 69 84

Greg Lowe

unread,
Dec 8, 2014, 4:12:12 AM12/8/14
to mi...@dartlang.org
Glad to hear that you're already working on it ;)

Anders Holmgren

unread,
Mar 15, 2015, 6:16:38 PM3/15/15
to mi...@dartlang.org, gr...@vis.net.nz
I just tried this in the latest dart dev vm and it doesn't like those sorts of urls. I've managed to get a unit test using scheduled_test to pass but never exit. I'd love to see what is on the event loop that is keeping it running. Any suggestions?
Reply all
Reply to author
Forward
0 new messages