irb icon indicating copy to clipboard operation
irb copied to clipboard

Fallback to non-colored inspect when coloring takes too long

Open osyoyu opened this issue 1 year ago • 1 comments

Inspecting large objects may take a long time since IRB colors the entire output of #inspect all at once. This patch lets IRB to give up coloring after a certain time and fall back to non-colored output. Changes can be observed by inspecting large Arrays, for example [1] * 1000000.

The default timeout is 2 seconds, but this can be configured through IRB.conf[:INSPECT_COLORING_TIMEOUT]. Passing nil to this option will disable timeouts (IRB will never fall back to non-colored output).

osyoyu avatar Nov 13 '23 16:11 osyoyu

Thanks for the PR 👍 However, it will not be the best solution to the problem because using timeout will cause hanging problems with debug for the irb:rdbg integration. See https://github.com/ruby/debug/issues/877

Maybe we should improve colour printer instead?

st0012 avatar Nov 18 '23 17:11 st0012