Skip to content

Fallback to non-colored inspect when coloring takes too long - #759

Closed
osyoyu wants to merge 1 commit into
ruby:masterfrom
osyoyu:coloring-timeout
Closed

osyoyu wants to merge 1 commit into
ruby:masterfrom
osyoyu:coloring-timeout

Conversation

@osyoyu

@osyoyu osyoyu commented Nov 13, 2023

Copy link
Copy Markdown

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).

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).
@st0012

st0012 commented Nov 18, 2023

Copy link
Copy Markdown
Member

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 ruby/debug#877

Maybe we should improve colour printer instead?

@tompng

tompng commented Jan 21, 2025

Copy link
Copy Markdown
Member

Thank you for this pull request and also for raising this issue.
The problem is reduced with another approach in #1040, by showing preview of first page quickly.

@tompng tompng closed this Jan 21, 2025
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

Successfully merging this pull request may close these issues.

3 participants