On 7/12/07, <b class="gmail_sendername">Eric Promislow</b> &lt;<a href="mailto:ericp@activestate.com">ericp@activestate.com</a>&gt; 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&#39;s loaded a web<br>page.&nbsp;&nbsp;They don&#39;t run into this in the ruby-debug debugger,<br>or running in normal mode.
<br><br>The reason: Komodo&#39;s debugger is graphical, which means that<br>whenever it hits a breakpoint it automatically shows the<br>contents of each local variable.&nbsp;&nbsp;It has a limit on how<br>much data it will retrieve, but it currently doesn&#39;t guard
<br>an object from loading too much data (which it should, but<br>that&#39;s a separate bug).<br><br>I can duplicate the cause of this crash in ruby-debug as<br>well.&nbsp;&nbsp;Here&#39;s a sample session, with this code:<br><br>require &#39;rubygems&#39;
<br>require &#39;mechanize&#39;<br>require &#39;logger&#39;<br><br>agent = WWW::Mechanize.new { |a| a.log = Logger.new(&quot;mech.log&quot;) }<br>agent.user_agent_alias = &#39;Mac Safari&#39;<br>page = agent.get(&quot;<a href="http://www.google.com/">
http://www.google.com/</a>&quot;)<br>search_form = page.forms.name(&quot;f&quot;).first<br>search_form.fields.name(&quot;q&quot;).value = &quot;bratislava tournament&quot;<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 &#39;rubygems&#39;<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&#39;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>&quot;#&lt;WWW::Mechanize::Link\n \&quot;iGoogle\&quot;\n \&quot;/url?sa=p&amp;pref=ig&amp;pval=3&amp;q=<a href="http://www.google.ca/ig%3Fhl%3Den&amp;usg=AFQjCNH9TTed08sJL_DKraFsuSMDFvW1gw\">
http://www.google.ca/ig%3Fhl%3Den&amp;usg=AFQjCNH9TTed08sJL_DKraFsuSMDFvW1gw\</a>&quot;&gt;\n&quot;<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~&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2007-07-12 10:55:20.375000000 -0700<br>+++ mechanize/inspect.rb&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2007-07-12 11:42:58.203125000 -0700<br>@@ -40,6 +40,7 @@<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alias :inspect&nbsp;&nbsp;:pretty_inspect<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;class Link<br>@@ -49,6 +50,7 @@<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;q.breakable; q.pp href<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alias :inspect&nbsp;&nbsp;:pretty_inspect
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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.&nbsp; I&#39;ll apply it and make sure the tests pass.&nbsp; :-)<br></div><br></div><br>-- <br>Aaron Patterson<br><a href="http://tenderlovemaking.com/">http://tenderlovemaking.com/
</a>