On 7/12/07, <b class="gmail_sendername">Eric Promislow</b> <<a href="mailto:ericp@activestate.com">ericp@activestate.com</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
The problem: users trying to debug Mechanize apps with Komodo<br>are finding the debugger times out once it's loaded a web<br>page. They don't run into this in the ruby-debug debugger,<br>or running in normal mode.
<br><br>The reason: Komodo's debugger is graphical, which means that<br>whenever it hits a breakpoint it automatically shows the<br>contents of each local variable. It has a limit on how<br>much data it will retrieve, but it currently doesn't guard
<br>an object from loading too much data (which it should, but<br>that's a separate bug).<br><br>I can duplicate the cause of this crash in ruby-debug as<br>well. Here's a sample session, with this code:<br><br>require 'rubygems'
<br>require 'mechanize'<br>require 'logger'<br><br>agent = WWW::Mechanize.new { |a| a.log = Logger.new("mech.log") }<br>agent.user_agent_alias = 'Mac Safari'<br>page = agent.get("<a href="http://www.google.com/">
http://www.google.com/</a>")<br>search_form = page.forms.name("f").first<br>search_form.fields.name("q").value = "bratislava tournament"<br>search_results = agent.submit(search_form)<br>
puts search_results.body<br><br>Given this ruby-debug session:<br><br>bugs $ rdebug mechanize01.rb<br>./mechanize01.rb:1 require 'rubygems'<br>(rdb:1) b 11<br>Set breakpoint 1 at mechanize01.rb:11<br>(rdb:1) c<br>
Breakpoint 1 at mechanize01.rb:11<br>./mechanize01.rb:11 puts search_results.body<br>(rdb:1) p page.links[0].inspect.size<br>1521039<br># That's way too big, since the page is a simple google results page:<br>(rdb:1) p
page.body.size<br>3441<br><br>Using mechanize/inspect.rb:<br><br>(rdb:1) p page.links[0].pretty_inspect<br>"#<WWW::Mechanize::Link\n \"iGoogle\"\n \"/url?sa=p&pref=ig&pval=3&q=<a href="http://www.google.ca/ig%3Fhl%3Den&usg=AFQjCNH9TTed08sJL_DKraFsuSMDFvW1gw\">
http://www.google.ca/ig%3Fhl%3Den&usg=AFQjCNH9TTed08sJL_DKraFsuSMDFvW1gw\</a>">\n"<br>(rdb:1) p page.links[0].pretty_inspect.size<br>138<br>(rdb:1) p page.inspect.size<br>1480219<br>(rdb:1) p page.pretty_inspect.size
<br>2172<br><br>With this change:<br>--- mechanize/inspect.rb~ 2007-07-12 10:55:20.375000000 -0700<br>+++ mechanize/inspect.rb 2007-07-12 11:42:58.203125000 -0700<br>@@ -40,6 +40,7 @@<br> }<br> }
<br> end<br>+ alias :inspect :pretty_inspect<br> end<br><br> class Link<br>@@ -49,6 +50,7 @@<br> q.breakable; q.pp href<br> }<br> end<br>+ alias :inspect :pretty_inspect
<br> end<br><br> class Form<br>lib $<br><br>I get these much better results:<br><br>(rdb:1) p page.links[0].inspect.size<br>138<br>(rdb:1) p page.body.size<br>3441<br>(rdb:1) p page.inspect.size<br>2172<br><br>Is this patch reasonable or have I missed something?
</blockquote><div><br>This patch seems reasonable. I'll apply it and make sure the tests pass. :-)<br></div><br></div><br>-- <br>Aaron Patterson<br><a href="http://tenderlovemaking.com/">http://tenderlovemaking.com/
</a>