Skip to content

hunk diff hangs at startup on long diff #1245

Open

Description

@rosensama

What happened?

Outside of whether it's a good idea to have this Jetbrains info in git in the first place ... the following diff seemed to be too much for hunk. hunk diff hangs with a blank screen on one roughly 10k-line XML diff; other files and repos work

for example:
hunk diff -- . ':!.idea/dataSources' works
hunk diff -- '.idea/dataSources/1156cc8c-78ca-46b5-9dad-b57888b713f9.xml' hangs

hunk 0.24.1 (Homebrew), macOS 27.2, arm64

Steps to reproduce

I don't really know what might be useful, so asked claude to help assemble. Apologies in advance for either of our ignorance.

The diff had the following attributes

❯ f='.idea/dataSources/1156cc8c-78ca-46b5-9dad-b57888b713f9.xml'                                                                                                                                                                                             
❯ wc -lc "$f"
   25078  864104 .idea/dataSources/1156cc8c-78ca-46b5-9dad-b57888b713f9.xml

❯ awk '{ if (length > m) m = length } END { print m }' "$f"
105

❯ git diff HEAD~1 HEAD -- "$f" | wc -c
 1027498

❯ git diff HEAD~1 HEAD --stat -- "$f"
.idea/dataSources/1156cc8c-78ca-46b5-9dad-b57888b713f9.xml | 10322 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------------
 1 file changed, 5497 insertions(+), 4825 deletions(-)

Observed

1. hunk diff and the spawned daemon both sit idle on an established localhost connection

hunk diff (pid 26077) holds an open TCP connection to the daemon:

hunk  26077  user  11u  IPv4  0xb544846bfd32627c  0t0  TCP localhost:61501->localhost:47657 (ESTABLISHED)

The daemon was spawned by that hunk diff process (PPID 26077), has no child processes (implying no git subprocess is pending?), and is idle:

PID PPID STAT ELAPSED %CPU CPU TIME COMMAND
26086 26077 Ss 02:22 0.0 0:00.20 hunk daemon serve

sample of the hung hunk diff (trimmed; full output attached as hunk.txt). hunk.txt

The main thread is parked in the event loop and the HTTP client thread is idle:

Thread_2232063  com.apple.main-thread
  └─ 4116 / 4128 samples in kevent64 (libsystem_kernel.dylib)
Thread_2232178  HTTP Client
  └─ 4128 / 4128 samples in kevent64 (libsystem_kernel.dylib)

2. Input and SIGTERM are ignored; hung processes persist detached

  • ESC, q, and Ctrl+C have no effect.
  • pkill -f hunk (SIGTERM) had no effect; pkill -9 -f hunk (SIGKILL) killed them.
  • Four orphaned hunk diff processes (/opt/homebrew/Cellar/hunk/0.24.1/libexec/hunk diff) from earlier attempts were still running hours later with no controlling terminal because I had killed the terminal while it was running:
PID STARTED TTY %CPU RSS CPU TIME
70198 12:23AM ?? 0.0 888 MiB 0:08.55
78637 12:27AM ?? 0.0 912 MiB 0:07.99
11815 12:43AM ?? 0.0 898 MiB 0:07.37
17059 12:45AM ?? 0.0 929 MiB 0:06.71

Expected behavior

hunk should display the diff or an error, either way remaining responsive

Version

0.24.1

Activity

  1. squad-joey commented on Oct 31, 2026

    @squad-joey
    Contributor

    I reproduced this on Linux (current main 33682090, Bun 1.4.4, PTY harness) with a fixture matching the reported shape: a 25k-line XML file (~824KB, under the 1MB source-text limit), 8256 lines changed with scattered interleaved changes across the file.

    Result: nowrap mode hangs — the app launches to a blank screen and never renders (the keyboard probe times out after 10s). Wrap mode renders fine on the same fixture.

    I also tested on the commit before #1241 (1b90e54d) — the hang reproduces there too, so this is not a #1241 regression. It's a pre-existing nowrap rendering issue for diffs with many interleaved changed/unchanged regions, distinct from the contiguous-block case #1241 addressed.

    This is a triage report, not a fix — the nowrap windowing path for scattered-change geometry needs investigation.

    This comment was generated by Pi using GLM-5.3-Flash

  2. squad-joey commented on Oct 31, 2026

    @squad-joey
    Contributor

    Correction to my triage above — I made a revision error. I tested on 33682090 calling it "current main," but that commit predates #1241. Current main is a4e2ff06, which includes #1241's nowrap windowing fix.

    Corrected results:

    Revision #1241 included? Nowrap mode Wrap mode
    1b90e54d (pre-#1241) No Hangs (blank screen) Renders
    33682090 (pre-#1241) No Hangs (blank screen) Renders
    a4e2ff06 (current main, post-#1241) Yes Renders Renders

    On current main a4e2ff06, the same fixture (25k-line XML, ~824KB, 8256/8256 changes) renders correctly in nowrap mode — the diff content appears with hunk headers and line numbers. The hang only exists on revisions before #1241.

    Conclusion: #1241's nowrap windowing fix resolves this hang. The reporter is on 0.24.1, which predates #1241 — upgrading to a release that includes #1241 should resolve it. This issue is a duplicate of the startup-hang aspect of the nowrap windowing problem that #1241 fixed, manifesting with a different file type (XML vs TypeScript) and change pattern (scattered vs contiguous), but the same underlying path.

    Apologies for the incorrect "distinct bug" claim in my earlier comment — the fixture was right but the revision was wrong.

    This comment was generated by Pi using GLM-5.3-Flash

  3. squad-joey commented on Oct 31, 2026

    @squad-joey
    Contributor

    Fair point — narrowing my conclusion: the synthetic fixture confirms the fix works for this shape of diff on current main, but the reporter's actual XML file and macOS environment haven't been tested. The right next step is to ask the reporter to confirm on a build containing #1241 (e.g., a canary or main build) before deciding whether to close this as a duplicate.

    This comment was generated by Pi using GLM-5.3-Flash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions